Dre4m Shell
Server IP : 103.6.199.200  /  Your IP : 3.145.10.68
Web Server : Microsoft-IIS/10.0
System : Windows NT EMPUSA 10.0 build 20348 (Windows Server 2016) i586
User : EMPUSA$ ( 0)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  C:/Domains/trackpro/trackprop.com/TrackPropNew/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : C:/Domains/trackpro/trackprop.com/TrackPropNew/RepUser.cs
using System;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Data.Entity;
using Property.Data;
using Property.Domain.Lookups;
using Property.Domain.Admin;
using Property.Repository.Common;
using Property.ADO;
using AutoMapper;
using System.Data.Objects.SqlClient;
using System.Numerics;
using System.Security.Cryptography;
using System.IO;


namespace Property.Repository.Admin
{
    public class RepUser : RepositoryBase<clsLookupUser, LookupUser>
    {
        public PropertyEntities db;
        public SQLDataAccess SPData;
        Dictionary<string, SqlParameter> cmdParameters;

        public RepUser()
        {
            db = new PropertyEntities();
            SPData = new SQLDataAccess();
            cmdParameters = new Dictionary<string, SqlParameter>();
        }

        public clsMail Saves(clsLookupUser ObjData)
        {

            try
            {
                ObjData.Active = true;
                ObjData.AuthCode = DateTime.Now.ToFileTimeUtc().ToString().Substring(6, 6);
                ObjData.DateCreated = DateTime.Now;

                if (Save(ObjData))
                {

                    string encoded_string = encrypt(ObjData.Email);

                    clsMail ObjMail = new clsMail();
                    ObjMail.body = @"<html>
<head>
</head>
<body>
    
        <div style='width:500px;height:600px;border: 2px groove #808080;border-radius: 20px;margin: 10px;padding: 10px;text-align: center;align-content: end;'>
            <div style='width:500px'>   <center> <img src='http://trackprop.com/wp-content/uploads/2015/08/logo12.png' style='max-height:100px'></center> </div>
            <div style='width:250px; height:200px; float:left;margin-top: 15px;'>
                <img src='http://i64.tinypic.com/k06d6p.png' style='max-width:240px'>
            </div>
            <div style='width:250px;height:200px;float:left;margin-top: 35px;'>
                <b style='font-size:40px'>Your Code for login  - <span style='color:#104b8b'>" + ObjData.AuthCode + @"</span></b>
            </div>
            <div style='width:500px;float:left;'>
                <p style='font-size:20px'>Please click the following link and enter the above code to complete the registration of TrackProp</p>
                <a href='http://www.trackprop.com/Home/UserVerification?Verify=" + encoded_string + @"'>http://www.trackprop.com/Home/UserVerification?Verify=" + encoded_string + @"</a>
            </div>
        </div>
   
</body>
</html>";
                    ObjMail.emailFrom = "support@trackprop.com";
                    ObjMail.emailTo = ObjData.Email + ",support@trackprop.com";
                    ObjMail.enableSSL = false;
                    ObjMail.password = "livetrack06^";
                    ObjMail.portNumber = 25;
                    ObjMail.smtpAddress = "mail.trackprop.com";
                    ObjMail.subject = "TrackProp - User Confirmation";
                    return ObjMail;
                }
                else
                {
                    return null;
                }
            }
            catch (Exception e)
            {
                throw e;
            }

        }

        public clsMail ForgotPassword(string EmailId)
        {

            try
            {

                var ObjUser = (from User in db.LookupUser
                               where User.Email == EmailId
                               && User.Active == true
                               && User.Status == true
                               select User).FirstOrDefault();

                if (ObjUser != null)
                {


                    ObjUser.AuthCode = DateTime.Now.ToFileTimeUtc().ToString().Substring(6, 6);
                    db.SaveChanges();



                    string encoded_string = encrypt(EmailId);








                    clsMail ObjMail = new clsMail();
                    ObjMail.body = @"<html>
<head>
</head>
<body>
    
        <div style='width:500px;height:600px;border: 2px groove #808080;border-radius: 20px;margin: 10px;padding: 10px;text-align: center;align-content: end;'>
            <div style='width:500px'>   <center> <img src='http://trackprop.com/wp-content/uploads/2015/08/logo12.png' style='max-height:100px'></center> </div>
            <div style='width:250px; height:200px; float:left;margin-top: 15px;'>
                <img src='http://i64.tinypic.com/k06d6p.png' style='max-width:240px'>
            </div>
            <div style='width:250px;height:200px;float:left;margin-top: 35px;'>
                <b style='font-size:40px'>Your Code for Rest Password  - <span style='color:#104b8b'>" + ObjUser.AuthCode + @"</span></b>
            </div>
            <div style='width:500px;float:left;'>
                <p style='font-size:20px'>Please click the following link and enter the above code to login and reset the password of TrackProp</p>
                <a href='http://www.trackprop.com/Home/UserVerification?Verify=" + encoded_string + @"'>http://www.trackprop.com/Home/UserVerification?Verify=" + encoded_string + @"</a>
            </div>
        </div>
   
</body>
</html>";
                    ObjMail.emailFrom = "support@trackprop.com";
                    ObjMail.emailTo = EmailId + ",support@trackprop.com";
                    ObjMail.enableSSL = false;
                    ObjMail.password = "livetrack06^";
                    ObjMail.portNumber = 25;
                    ObjMail.smtpAddress = "mail.trackprop.com";
                    ObjMail.subject = "TrackProp - Reset Password";
                    return ObjMail;
                }
                else
                {
                    return null;
                }
            }
            catch (Exception e)
            {
                throw e;
            }

        }

        public clsLookupUser IsValidUser(string UserName, String Password)
        {


            try
            {

                var ObjLogin = (from User in db.LookupUser
                                join Role in db.LookupRole
                                on User.RoleId equals (Role.ID)
                                where User.Email == UserName
                                && User.Password == Password
                                && User.Active == true
                                && User.Status == true
                                select new clsLookupUser
                                        {
                                            UserId = User.UserId,
                                            UserName = User.UserName,
                                            FirstName = User.FirstName,
                                            Password = User.Password,
                                            RoleId = (Int32)User.RoleId,
                                            Type = User.Type,
                                            PropertyId = User.PropertyId
                                        }).FirstOrDefault();

                if (ObjLogin != null)
                {
                    if (ObjLogin.RoleId > 3) { return null; };
                }
                return ObjLogin;

            }

            catch (Exception e)
            {
                return null;
            }

            finally { }

        }
        public clsLookupUser IsValidUserBuilding(string UserName, String Password)
        {


            try
            {

                var ObjLogin = (from User in db.LookupUser
                                join Role in db.LookupRole
                                on User.RoleId equals (Role.ID)
                                where User.Email == UserName
                                && User.Password == Password
                                && User.Active == true
                                && User.Status == true
                                select new clsLookupUser
                                {
                                    UserId = User.UserId,
                                    UserName = User.UserName,
                                    FirstName = User.FirstName,
                                    Password = User.Password,
                                    RoleId = (Int32)User.RoleId,
                                    Type = User.Type,
                                    PropertyId = User.PropertyId
                                }).OrderByDescending(x => x.UserId).FirstOrDefault();

                if (ObjLogin != null)
                {


                    if (ObjLogin.Type == 2 || ObjLogin.RoleId == 2)
                    {



                        if (ObjLogin.RoleId == 2)
                        {
                            var BuildingProp = (from Prop in db.LookupProperty
                                                where Prop.IsBuildingManagement == true
                                                && Prop.CreatedBy == ObjLogin.UserId
                                                select Prop.PropertyTitle).FirstOrDefault();

                            if (BuildingProp == null)
                            {
                                return null;
                            }
                        }



                        string PropertyName = "";
                        PropertyName = (from Prop in db.LookupProperty
                                        where Prop.PropertyId == ObjLogin.PropertyId
                                        select Prop.PropertyTitle).FirstOrDefault();

                        ObjLogin.PropertyName = PropertyName;
                        return ObjLogin;
                    }
                    else
                    {
                        return null;
                    }

                }
                else
                {
                    return null;
                }


            }

            catch (Exception e)
            {
                return null;
                throw e;
            }

            finally { }

        }

        public clsLookupUser IsValidUserRent(string UserName, string Password, string UserType)
        {
            try
            {
                var ObjLogin = (from User in db.LookupUser
                                join Role in db.LookupRole
                                on User.RoleId equals (Role.ID)
                                where User.Email == UserName
                                && User.Password == Password
                                && (Role.Name == UserType || Role.Name == "Admin")
                                && User.Active == true
                                && User.Status == true
                                select new clsLookupUser
                                {
                                    UserId = User.UserId,
                                    UserName = User.UserName,
                                    FirstName = User.FirstName,
                                    Password = User.Password,
                                    RoleId = (Int32)User.RoleId,
                                    Type = User.Type,
                                    PropertyId = User.PropertyId
                                }).FirstOrDefault();

                if (ObjLogin != null)
                {
                    return ObjLogin;
                }
                else
                {
                    return null;
                }
            }

            catch (Exception e)
            {
                return null;
                throw e;
            }

            finally { }

        }

        public clsLookupUser VerifyUser(string Email, string AuthCode)
        {


            try
            {

                var ObjLogin = (from User in db.LookupUser
                                where User.Email == Email
                                && User.AuthCode == AuthCode
                                && User.Active == true
                                && User.Status == true
                                select new clsLookupUser
                                {
                                    UserId = User.UserId,
                                    UserName = User.UserName,
                                    FirstName = User.FirstName,
                                    Password = User.Password,
                                    RoleId = (Int32)User.RoleId,
                                    Type = User.Type,
                                    PropertyId = User.PropertyId

                                }).FirstOrDefault();

                if (ObjLogin != null && ObjLogin.PropertyId != null)
                {
                    string PropertyName = "";
                    PropertyName = (from Prop in db.LookupProperty
                                    where Prop.PropertyId == ObjLogin.PropertyId
                                    select Prop.PropertyTitle).FirstOrDefault();

                    ObjLogin.PropertyName = PropertyName;
                }
                return ObjLogin;

            }

            catch (Exception e)
            {
                return null;
                throw e;
            }

            finally { }

        }
        public string CheckUserExistance(clsLookupUser ObjData)
        {

            try
            {

                int result = (from User in db.LookupUser
                              where User.Email == ObjData.Email && User.Status == true
                              select User).Count();
                if (result > 0)
                {
                    return "Email Already Exists";
                }
                else
                {

                    return "Success";

                }


            }


            catch (Exception e)
            {
                throw e;
            }

            finally { }
        }

        public DataTable GetAllValiduser(string UserName, string Password)
        {
            cmdParameters["UserName"] = new SqlParameter("@username", UserName);
            cmdParameters["Password"] = new SqlParameter("@password", Password);
            return SPData.ExecuteQuery("[spGetValidUser]", cmdParameters);
        }
        public IList<string> CheckAccessPermission(int RoleId)
        {

            try
            {

                return (from Map in db.LookupPageMapping
                        join Page in db.LookupPage on Map.PageId equals Page.ID
                        where Map.RoleId == RoleId && Map.Status == true
                        select Page.URL).ToList();

            }

            catch (Exception e)
            {
                return null;
                throw e;
            }

            finally { }

        }

        public DataTable GetAll(string Type, string PropertyId)
        {
            cmdParameters["Type"] = new SqlParameter("@Type", Type);
            cmdParameters["PropertyId"] = new SqlParameter("@PropertyId", PropertyId);
            return SPData.ExecuteQuery("GetAllUsers", cmdParameters);
        }

        public DataTable GetAllCreditRequestUsers()
        {
            return SPData.ExecuteQuery("GetAllCreditRequestUsers", cmdParameters);
        }


        public DataTable GetApprovalList()
        {
            return SPData.ExecuteQuery("GetApprovalList", cmdParameters);
        }

        public DataTable GetRentApprovalList()
        {
            return SPData.ExecuteQuery("GetRentOrSellApprovalList", cmdParameters);
        }

        public DataTable GetAllBuildingManagementApprovalList()
        {
            return SPData.ExecuteQuery("GetAllBuildingManagementApprovalList", cmdParameters);
        }

        public DataTable GetAllCompletedPropertyForBM()
        {
            return SPData.ExecuteQuery("GetAllCompletedPropertyForBM", cmdParameters);
        }

        public DataTable GetFavoriteList(string UserId)
        {
            cmdParameters["UserId"] = new SqlParameter("@UserId", UserId);
            return SPData.ExecuteQuery("GetFavoriteList", cmdParameters);
        }

        public DataTable GetAllRoleTypeUser(int RoleId)
        {
            cmdParameters["RoleId"] = new SqlParameter("@RoleId", RoleId);
            return SPData.ExecuteQuery("spGetAllRoleTypeUser", cmdParameters);
        }

        public DataTable GetUserProfile(int UserId)
        {
            cmdParameters["UserId"] = new SqlParameter("@UserId", UserId);
            return SPData.ExecuteQuery("[SpGetUserDetails]", cmdParameters);
        }


        public bool Favorite(int PropertyId, int UserId, bool IsFavorite)
        {


            try
            {

                var ObjUserActivity = (from User in db.UserActivity

                                       where User.UserId == UserId
                                       && User.PropertyId == PropertyId
                                       && User.Status == true
                                       select User).FirstOrDefault();


                if (ObjUserActivity == null)
                {
                    ObjUserActivity = new UserActivity();
                    ObjUserActivity.PropertyId = PropertyId;
                    ObjUserActivity.UserId = UserId;
                    ObjUserActivity.IsFavorite = IsFavorite;
                    ObjUserActivity.FavoriteDate = DateTime.Now;
                    ObjUserActivity.Status = true;
                    db.UserActivity.AddObject(ObjUserActivity);
                    db.SaveChanges();
                }
                else
                {
                    ObjUserActivity.IsFavorite = IsFavorite;
                    ObjUserActivity.FavoriteDate = DateTime.Now;
                    db.SaveChanges();
                }

                return true;

            }

            catch (Exception e)
            {
                throw e;
            }

            finally { }

        }


        public DataTable GetNotification(int RoleId, int UserId, string CheckDateTime)
        {
            cmdParameters["RoleId"] = new SqlParameter("@RoleId", RoleId);
            cmdParameters["UserId"] = new SqlParameter("@UserId", UserId);
            cmdParameters["CheckDateTime"] = new SqlParameter("@CheckDateTime", CheckDateTime);
            return SPData.ExecuteQuery("[GetNotification]", cmdParameters);
        }


        public string encrypt(string encryptString)
        {
            string EncryptionKey = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            byte[] clearBytes = Encoding.Unicode.GetBytes(encryptString);
            using (Aes encryptor = Aes.Create())
            {
                Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(EncryptionKey, new byte[] {  
                    0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76  
                    });
                encryptor.Key = pdb.GetBytes(32);
                encryptor.IV = pdb.GetBytes(16);
                using (MemoryStream ms = new MemoryStream())
                {
                    using (CryptoStream cs = new CryptoStream(ms, encryptor.CreateEncryptor(), CryptoStreamMode.Write))
                    {
                        cs.Write(clearBytes, 0, clearBytes.Length);
                        cs.Close();
                    }
                    encryptString = Convert.ToBase64String(ms.ToArray());
                }
            }
            return encryptString;
        }

        public string Decrypt(string cipherText)
        {
            string EncryptionKey = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            cipherText = cipherText.Replace(" ", "+");
            byte[] cipherBytes = Convert.FromBase64String(cipherText);
            using (Aes encryptor = Aes.Create())
            {
                Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(EncryptionKey, new byte[] {  
                0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76  
            });
                encryptor.Key = pdb.GetBytes(32);
                encryptor.IV = pdb.GetBytes(16);
                using (MemoryStream ms = new MemoryStream())
                {
                    using (CryptoStream cs = new CryptoStream(ms, encryptor.CreateDecryptor(), CryptoStreamMode.Write))
                    {
                        cs.Write(cipherBytes, 0, cipherBytes.Length);
                        cs.Close();
                    }
                    cipherText = Encoding.Unicode.GetString(ms.ToArray());
                }
            }
            return cipherText;
        }

        public DataTable GetUserCreditManagementDeatils(int UserId)
        {
            cmdParameters["UserId"] = new SqlParameter("@UserId", UserId);
            return SPData.ExecuteQuery("spGetUserCreditManagementDeatils", cmdParameters);
        }

        public DataTable GetCreditDeatilsByAdmin()
        {
            return SPData.ExecuteQuery("spGetCreditDeatilsByAdmin", cmdParameters);
        }

        public DataTable GetCreditDeatilsByUser(int UserId)
        {
            cmdParameters["UserId"] = new SqlParameter("@UserId", UserId);
            return SPData.ExecuteQuery("spGetCreditDeatilsByUser", cmdParameters);
        }
        //public bool SaveCreditManagement(int UserId, int Credits, bool Status)
        //{


        //    try
        //    {

        //        var ObjUserActivity = (from User in db.UserActivity

        //                               where User.UserId == UserId
        //                               && User.PropertyId == PropertyId
        //                               && User.Status == true
        //                               select User).FirstOrDefault();


        //        if (ObjUserActivity == null)
        //        {
        //            ObjUserActivity = new CreditManagement();
        //            ObjUserActivity.PropertyId = PropertyId;
        //            ObjUserActivity.UserId = UserId;
        //            ObjUserActivity.IsFavorite = IsFavorite;
        //            ObjUserActivity.FavoriteDate = DateTime.Now;
        //            ObjUserActivity.Status = true;
        //            db.UserActivity.AddObject(ObjUserActivity);
        //            db.SaveChanges();
        //        }
        //        else
        //        {
        //            ObjUserActivity.IsFavorite = IsFavorite;
        //            ObjUserActivity.FavoriteDate = DateTime.Now;
        //            db.SaveChanges();
        //        }

        //        return true;

        //    }

        //    catch (Exception e)
        //    {
        //        throw e;
        //    }

        //    finally { }

        //}

        public bool SaveCreditManagement(int UserId, int Credits, int Status, int SessionUserId)
        {
            try
            {

                var ObjCreditManagement = (from cm in db.CreditManagement
                                           where cm.UserId == UserId
                                           select cm).FirstOrDefault();
                if (ObjCreditManagement == null)
                {
                    ObjCreditManagement = new CreditManagement();
                    ObjCreditManagement.UserId = UserId;
                    ObjCreditManagement.TotalCredits = 0;
                    ObjCreditManagement.UsedCredits = 0;
                    ObjCreditManagement.AvailableCredits = 0;
                    ObjCreditManagement.RequestedCredits = Credits;
                    ObjCreditManagement.RequestedBy = UserId;
                    ObjCreditManagement.RequestedDateTime = System.DateTime.Now;
                    db.CreditManagement.AddObject(ObjCreditManagement);
                    db.SaveChanges();
                }
                else
                {
                    if (Status == 1)//Requested
                    {
                        ObjCreditManagement.RequestedCredits = Credits;
                        ObjCreditManagement.RequestedBy = UserId;
                        ObjCreditManagement.RequestedDateTime = System.DateTime.Now;
                    }
                    else if (Status == 2)//Approved
                    {
                        ObjCreditManagement.TotalCredits = (ObjCreditManagement.TotalCredits + Credits);
                        ObjCreditManagement.AvailableCredits = (ObjCreditManagement.AvailableCredits + Credits);
                        ObjCreditManagement.RequestedCredits = 0;
                        ObjCreditManagement.ApprovedBy = SessionUserId;
                        ObjCreditManagement.ApprovedDateTime = DateTime.Now;
                    }
                    else if (Status == 3)//Rejected
                    {
                        ObjCreditManagement.RequestedCredits = 0;
                    }
                    else if (Status == 4)//Use Credits
                    {
                        ObjCreditManagement.AvailableCredits = (ObjCreditManagement.AvailableCredits - Credits);
                        ObjCreditManagement.UsedCredits = (ObjCreditManagement.UsedCredits + Credits);
                    }
                    db.SaveChanges();
                }
                return true;
            }
            catch (Exception e)
            {
                throw e;
            }
            finally { }
        }


    }

}

Anon7 - 2022
AnonSec Team