Пример #1
0
        public bool Delete(Landlord landlord, Database db, DbTransaction transaction)
        {
            DbCommand command = db.GetStoredProcCommand("usp_LandlordDelete");

            db.AddInParameter(command, "LandlordId", DbType.Guid, landlord.LandlordId);

            db.ExecuteNonQuery(command, transaction);

            return true;
        }
Пример #2
0
        public bool Delete(Landlord landlord, Database db, DbTransaction transaction)
        {
            DbCommand command = db.GetStoredProcCommand("usp_LandlordDelete");

            db.AddInParameter(command, "LandlordId", DbType.Guid, landlord.LandlordId);

            db.ExecuteNonQuery(command, transaction);

            return(true);
        }
Пример #3
0
        public Landlord GetLandlordByRoomId(Guid roomId)
        {
            Landlord returnLandlord = new Landlord();

            Database db = DatabaseFactory.CreateDatabase(Constants.CONNECTIONSTRING);
            DbCommand dbCommand = db.GetStoredProcCommand("usp_HouseSelect");

            db.AddInParameter(dbCommand, "HouseId", DbType.Guid, roomId);

            return returnLandlord;
        }
Пример #4
0
        /// <summary>
        /// Checks if user record with UserId exist in User table of the database.
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public bool IsLandlordExist(Landlord landlord)
        {
            Database db = DatabaseFactory.CreateDatabase(Constants.CONNECTIONSTRING);
            DbCommand command = db.GetStoredProcCommand("usp_Landlord_IsLandlordExist");

            db.AddInParameter(command, "LandlordId", DbType.Guid, landlord.LandlordId);
            db.AddOutParameter(command, "IsExist", DbType.Boolean, 1);

            db.ExecuteNonQuery(command);

            return Convert.ToBoolean(db.GetParameterValue(command, "IsExist").ToString());
        }
Пример #5
0
        /// <summary>
        /// Checks if user record with UserId exist in User table of the database.
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>

        public bool IsLandlordExist(Landlord landlord)
        {
            Database  db      = DatabaseFactory.CreateDatabase(Constants.CONNECTIONSTRING);
            DbCommand command = db.GetStoredProcCommand("usp_Landlord_IsLandlordExist");

            db.AddInParameter(command, "LandlordId", DbType.Guid, landlord.LandlordId);
            db.AddOutParameter(command, "IsExist", DbType.Boolean, 1);

            db.ExecuteNonQuery(command);

            return(Convert.ToBoolean(db.GetParameterValue(command, "IsExist").ToString()));
        }
Пример #6
0

        
Пример #7
0
        public bool Update(Landlord landlord, Database db, DbTransaction transaction)
        {
            DbCommand command = db.GetStoredProcCommand("usp_LandlordUpdate");

            db.AddInParameter(command, "LandlordId", DbType.Guid, landlord.LandlordId);
            db.AddInParameter(command, "UserId", DbType.Guid, landlord.user.UserId);
            db.AddInParameter(command, "LandlordName", DbType.String, landlord.LandlordName);
            db.AddInParameter(command, "IsDeleted", DbType.Boolean, landlord.IsDeleted);
            db.AddInParameter(command, "UpdatedBy", DbType.Guid, landlord.UpdatedBy);
            db.AddInParameter(command, "LandlordTypeId", DbType.Int32, landlord.LandlordTypeId);
            db.AddOutParameter(command, "UpdatedDate", DbType.DateTime, 30);

            db.ExecuteNonQuery(command, transaction);

            landlord.CreatedDate = Convert.ToDateTime(db.GetParameterValue(command, "UpdatedDate").ToString());
            landlord.UpdatedDate = landlord.CreatedDate;

            return true;
        }
Пример #8
0
        public bool Update(Landlord landlord, Database db, DbTransaction transaction)
        {
            DbCommand command = db.GetStoredProcCommand("usp_LandlordUpdate");

            db.AddInParameter(command, "LandlordId", DbType.Guid, landlord.LandlordId);
            db.AddInParameter(command, "UserId", DbType.Guid, landlord.user.UserId);
            db.AddInParameter(command, "LandlordName", DbType.String, landlord.LandlordName);
            db.AddInParameter(command, "IsDeleted", DbType.Boolean, landlord.IsDeleted);
            db.AddInParameter(command, "UpdatedBy", DbType.Guid, landlord.UpdatedBy);
            db.AddInParameter(command, "LandlordTypeId", DbType.Int32, landlord.LandlordTypeId);
            db.AddOutParameter(command, "UpdatedDate", DbType.DateTime, 30);

            db.ExecuteNonQuery(command, transaction);

            landlord.CreatedDate = Convert.ToDateTime(db.GetParameterValue(command, "UpdatedDate").ToString());
            landlord.UpdatedDate = landlord.CreatedDate;

            return(true);
        }
Пример #9
0
        public static Landlord SelectByBaseHouseRoomId(Guid BaseHouseRoomId)
        {
            Landlord landlord = Generic.GetByFieldValue <Landlord>("BaseHouseRoomId", BaseHouseRoomId.ToString());

            return(landlord);
        }
Пример #10
0
        public static Landlord Select(Guid Userid)
        {
            Landlord landlord = Generic.GetByFieldValue <Landlord>("Userid", Userid.ToString());

            return(landlord);
        }
        public bool SaveLandload()
        {
            bool result = true;
            aspnet_Roles aspnet_Roles_ = new aspnet_Roles();

            Landlord landload = new Landlord();

            aspnet_Roles_ = aspnet_Roles.Select("landlord");

            User Landlorduser = new User();
            if (hdLandloadId.Value != null && hdLandloadId.Value != string.Empty)
            {

                Landlorduser.UserId = Guid.Parse(hdLandloadId.Value);
                Landlorduser.PersonalEmail = LandloadEmail.Text.Trim();
                Landlorduser.FirstName = LandloadFirstName.Text.Trim();
                Landlorduser.MiddleName = LandloadMiddleName.Text.Trim();
                Landlorduser.LastName = LandloadLastName.Text.Trim();
                Landlorduser.BestContactNumber = LandloadMobileArea.Text.Trim() + LandloadMobile1.Text.Trim() + LandloadMobile2.Text.Trim();//Mobile.Text.Trim();
                Landlorduser.CreatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                Landlorduser.UpdatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                Landlorduser.IsPartialUser = true;
                Landlorduser.RoleId = aspnet_Roles_.RoleId;
                Landlorduser.UpdatedDate = DateTime.Now;

                if (Landlorduser.Save())
                {
                    landload.user = Landlorduser;
                    landload.LandlordId = Landlorduser.UserId.HasValue ? Landlorduser.UserId.Value : Landlorduser.UserId.Value;
                    landload.LandlordName = Landlorduser.FirstName + " " + Landlorduser.MiddleName + " " + Landlorduser.LastName;

                    landload.CreatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                    landload.UpdatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                    result = landload.Save();

                    string strMsgContent = Landloadmessage(Landlorduser.UserId.Value, Landlorduser);

                    string strMsgTitle = SystemConfig.GetValue(RHP.Common.Enums.SystemConfig.SITEURL) + " is Requesting you to join with Us.";

                    int rtn = LandloadSendEmail(Landlorduser.PersonalEmail, strMsgTitle, strMsgContent);

                    if (rtn == 1)
                    {
                    }
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Save_Success + "'); window.location = '/Student/Student_Profile_Update_Current_House.aspx';}", true);

                }

            }
            else
            {
                LandloadLabelmessage.Text = "Landlord Details cannot saved.Please try again!";
                // no  Landload id
            }
            return result;
        }
        public void LoadUserData()
        {
            // user data
            user = User.Select(Guid.Parse(Membership.GetUser().ProviderUserKey.ToString()));

            user.UserId = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
            user.AspnetUserId = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
            FirstName.Text = string.IsNullOrEmpty(user.FirstName) ? string.Empty : user.FirstName;
            MiddleName.Text = string.IsNullOrEmpty(user.MiddleName) ? string.Empty : user.MiddleName;
            LastName.Text = string.IsNullOrEmpty(user.LastName) ? string.Empty : user.LastName;
            Email.Text = string.IsNullOrEmpty(Membership.GetUser().Email.ToString()) ? string.Empty : Membership.GetUser().Email.ToString();
            Address.Text = string.IsNullOrEmpty(user.StreetAddress) ? string.Empty : user.StreetAddress;
            City.Text = string.IsNullOrEmpty(user.City) ? string.Empty : user.City;
            Zip.Text = string.IsNullOrEmpty(user.Zip) ? string.Empty : user.Zip;
            //Mobile.Text = string.IsNullOrEmpty(user.BestContactNumber) ? string.Empty : user.BestContactNumber;

            MobileArea.Text = string.IsNullOrEmpty(user.BestContactNumber) ? string.Empty : user.BestContactNumber.Substring(0, 3);
            Mobile1.Text = string.IsNullOrEmpty(user.BestContactNumber) ? string.Empty : user.BestContactNumber.Substring(3, 3);
            Mobile2.Text = string.IsNullOrEmpty(user.BestContactNumber) ? string.Empty : user.BestContactNumber.Substring(6, 4);

            DOB.Text = string.IsNullOrEmpty(user.DateOfBirth.ToString()) ? string.Empty : user.DateOfBirth.Value.ToShortDateString();

            if (user.StateId.HasValue)
            {
                for (int i = 0; i < Drpstate.Items.Count; i++)
                {
                    if (Drpstate.Items[i].Value.ToString().ToLower() == user.StateId.ToString().ToLower())
                    {
                        Drpstate.ClearSelection();
                        Drpstate.Items[i].Selected = true;
                    }
                }
            }

            if (!string.IsNullOrEmpty(user.Gender))
            {
                for (int i = 0; i < DrpGender.Items.Count; i++)
                {
                    if (DrpGender.Items[i].Value.ToString().ToLower() == user.Gender.ToLower())
                    {
                        DrpGender.ClearSelection();
                        DrpGender.Items[i].Selected = true;
                    }
                }
            }

            landload = Landlord.Select(Guid.Parse(Membership.GetUser().ProviderUserKey.ToString()));
        }
Пример #13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string ReturnURL = string.Empty;
            string userRole = string.Empty;
            Uri currentDomainURL = new Uri(HttpContext.Current.Request.Url.AbsoluteUri);

            string value = Utility.GetQueryStringValueByKey(Request, "type");

            if (!IsPostBack)
            {

                if (value == "s")
                {
                    ReturnURL = "/Student/Student_Profile.aspx";
                    userRole = "student";
                }
                else if (value == "l")
                {
                    ReturnURL = "/Land_load/Land_load_Profile.aspx";
                    userRole = "landlord";
                }
                else
                {
                    ReturnURL = "~/";
                }
            }

            try
            {
                IAuthorizationState authorization = facebookClient.ProcessUserAuthorization();

                User user = new User();
                RHP.StudentManagement.Student student = new RHP.StudentManagement.Student();

                Landlord landload = new Landlord();

                if (authorization == null)
                {
                    SendEmail("FBReturn URL", string.Format("Return URL: {0}, App Id: {1}, App Secret: {2}", currentDomainURL.ToString(),
                        facebookClient.ClientIdentifier.ToString(), facebookClient.ClientCredentialApplicator.ToString()));
                    facebookClient.RequestUserAuthorization(scope: new[] { FBClient.Scopes.Email }, returnTo: currentDomainURL);
                }
                else// if (authorization.Scope.Count > 0)
                {
                    string accessCode = string.Empty;
                    if (authorization != null && authorization.AccessToken != null)
                    {
                        accessCode = Uri.EscapeDataString(authorization.AccessToken);
                    }

                    IOAuth2Graph oauth2Graph = facebookClient.GetGraph(authorization, new[] { FBGraph.Fields.Defaults, FBGraph.Fields.Email, FBGraph.Fields.Picture });

                    //Todo: Register the user here if not an existing member.
                    user.FBid = string.IsNullOrEmpty(HttpUtility.HtmlEncode(oauth2Graph.Id)) ? string.Empty : HttpUtility.HtmlEncode(oauth2Graph.Id);

                    user.FirstName = string.IsNullOrEmpty(HttpUtility.HtmlEncode(oauth2Graph.FirstName)) ? string.Empty : HttpUtility.HtmlEncode(oauth2Graph.FirstName);
                    user.LastName = string.IsNullOrEmpty(HttpUtility.HtmlEncode(oauth2Graph.LastName)) ? string.Empty : HttpUtility.HtmlEncode(oauth2Graph.LastName);
                    user.Email = string.IsNullOrEmpty(HttpUtility.HtmlEncode(oauth2Graph.Email)) ? string.Empty : HttpUtility.HtmlEncode(oauth2Graph.Email);
                    user.PersonalEmail = string.IsNullOrEmpty(HttpUtility.HtmlEncode(oauth2Graph.Email)) ? string.Empty : HttpUtility.HtmlEncode(oauth2Graph.Email);
                    user.FBAccessToken = string.IsNullOrEmpty(authorization.AccessToken) ? string.Empty : authorization.AccessToken;
                    user.FBProfilePictureURL = string.IsNullOrEmpty(HttpUtility.HtmlEncode(oauth2Graph.AvatarUrl)) ? string.Empty : HttpUtility.HtmlEncode(oauth2Graph.AvatarUrl);
                    user.Gender = string.IsNullOrEmpty(HttpUtility.HtmlEncode(oauth2Graph.Gender)) ? string.Empty : HttpUtility.HtmlEncode(oauth2Graph.Gender);
                    user.IsFBUser = true;
                    user.Password = user.FBid;
                    user.UserName = user.FBid;
                    user.Question = "Are you FB User ?";
                    user.Answer = "FB" + user.FBid;

                    if (user.IsExistingFbUser(user.FBid))
                    {
                        // authanticate fbuser get userneame and pwd
                        // get user from fbid (username)
                        // stringpassword = membership

                        user.UserName = user.GetFBUsernameByFBId(user.FBid);

                        if (user.AuthenticateUser())
                        {
                            try
                            {
                                Session[Constants.SESSION_LOGGED_USER] = user;
                                user.RedirectUserFromLogin(false);
                            }
                            catch (Exception ex)
                            {
                                user.LogOut();
                            }
                        }
                        else
                        {
                            user.LogOut();
                        }

                    }
                    else
                    {

                        if (user.IsUserEmailExist(user.Email))
                        {
                            //Todo need to handle this part correctly.
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.EmailExist + "'); window.location = '/Login.aspx'; }", true);

                        }
                        else
                        {
                            bool boolMembershipUserCreated = false;
                            object objCreateMembershipUser = new object();

                            user.UserId = Guid.NewGuid();
                            objCreateMembershipUser = user.AddMembershipPartialUser(user.UserName, user.Password, user.Email, user.Question, user.Answer, true, user.UserId.Value, userRole);

                            bool.TryParse(objCreateMembershipUser.ToString(), out boolMembershipUserCreated);

                            if (boolMembershipUserCreated)
                            {
                                FormsAuthentication.SetAuthCookie(user.UserName, false);
                                user.UpdatedBy = user.UserId.HasValue ? user.UserId.Value : Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                                user.CreatedBy = user.UserId.HasValue ? user.UserId.Value : Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());

                                if (user.Save())
                                {
                                    Session[Constants.SESSION_LOGGED_USER] = user;
                                    MembershipUser newUser = Membership.GetUser(user.UserName);
                                    user.RedirectUserFromLogin(true);
                                }
                                else
                                {
                                    user.LogOut();
                                    //Todo delete membership user from tables
                                    Response.Redirect("~/Login.aspx", false);
                                }
                            }
                            else
                            {
                                user.LogOut();
                                Response.Redirect("~/Login.aspx", false);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                string emailText = String.Format("Message:{0}, Source:{1}, StackTrace:{2}", ex.Message, ex.Source, ex.StackTrace);
                SendEmail("FB Exception", emailText);
                throw ex;
            }
        }
Пример #14
0
        public Guid SaveLandload(int baseHouseId)
        {
            Guid landlordId;

            List<BaseHouse> dormHouses = BaseHouseDAO.SelectAllByHouseTypeId(HouseTypeId);
            CurrentHouse = dormHouses.Find(bh => bh.BaseHouseId == baseHouseId);
            if (CurrentHouse.LandlordId.HasValue)
            {
                landlordId = CurrentHouse.LandlordId.Value;
            }
            else
            {
                aspnet_Roles aspnet_Roles_ = new aspnet_Roles();
                Landlord landload = new Landlord();
                aspnet_Roles_ = aspnet_Roles.Select("landlord");

                User Landlorduser = new User();

                Landlorduser.UserId = Guid.NewGuid();
                landlordId = Landlorduser.UserId.Value;

                Landlorduser.PersonalEmail = CurrentHouse.ManagerEmail;
                Landlorduser.FirstName = CurrentHouse.PropertyManagementCompanyName;
                Landlorduser.BestContactNumber = CurrentHouse.PhoneNumber;
                Landlorduser.CreatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                Landlorduser.UpdatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                Landlorduser.IsPartialUser = true;
                Landlorduser.RoleId = aspnet_Roles_.RoleId;
                Landlorduser.UpdatedDate = DateTime.Now;

                if (Landlorduser.Save())
                {
                    landload.user = Landlorduser;
                    landload.LandlordId = Landlorduser.UserId.Value;
                    landload.LandlordName = Landlorduser.FirstName;
                    landload.IsDeleted = false;
                    landload.LandlordTypeId = (int)Enums.LandlordType.CorporateLandlord;
                    landload.CreatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                    landload.UpdatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());

                    if (landload.Save())
                    {
                        //Todo: Update the basehouse table with the new LandlordId
                        CurrentHouse.LandlordId = landlordId;
                        CurrentHouse.CreatedBy = Membership.GetUser().UserName;
                        CurrentHouse.UpdatedBy = Membership.GetUser().UserName;
                        if (CurrentHouse.Save())
                        {
                            //Base House is updated with new landlord id
                        }
                    }
                }
            }
            return landlordId;
        }