Exemplo n.º 1
0
        /// <summary>
        /// Logs the in information.
        /// </summary>
        /// <param name="userType">Type of the user.</param>
        /// <returns></returns>
        public ActionResult LogInInfo(int userType)
        {
            string userName = string.Empty;
            if (userType == 1)
            {
                LandlordRegister LandlordModel = new LandlordRegister();
                int userid = Convert.ToInt32(FormsAuthentication.Decrypt(Request.Cookies[FormsAuthentication.FormsCookieName].Value).Name);
                var landlordModel = dbContext.LandlordRegistrations.FirstOrDefault(r => r.LandlordId == userid && r.IsActive == true);
                userName = landlordModel != null ? landlordModel.FirstName + " " + landlordModel.LastName : string.Empty;
            }
            else if (userType == 2)
            {
                int tenantId = Convert.ToInt32(FormsAuthentication.Decrypt(Request.Cookies[FormsAuthentication.FormsCookieName].Value).Name);
                var tenantModel = dbContext.TenantRegistrations.FirstOrDefault(c => c.TenantId == tenantId && c.IsActive == true);
                userName = tenantModel != null ? tenantModel.FirstName + " " + tenantModel.LastName : string.Empty;

            }
            ViewBag.UserName = userName;
            return PartialView("_LogInInfo");
        }
Exemplo n.º 2
0
 /// <summary>
 /// Gets the current landlord details.
 /// </summary>
 /// <returns></returns>
 private LandlordRegister GetCurrentLandlordDetails()
 {
     LandlordRegister LandlordModel = new LandlordRegister();
     int userid = Convert.ToInt32(FormsAuthentication.Decrypt(Request.Cookies[FormsAuthentication.FormsCookieName].Value).Name);
     var landlordEntity = dbContext.LandlordRegistrations.FirstOrDefault(r => r.LandlordId == userid);
     if (landlordEntity != null)
     {
         LandlordModel.ID = landlordEntity.LandlordId;
         LandlordModel.FirstName = landlordEntity.FirstName;
         LandlordModel.LastName = landlordEntity.LastName;
         LandlordModel.PPSNNO = landlordEntity.PPSNNO;
     }
     return LandlordModel;
 }
Exemplo n.º 3
0
        public ActionResult LandlordRegister(LandlordRegister model)
        {
            if (ModelState.IsValid)
            {
                var isLandlordExit = dbContext.LandlordRegistrations.FirstOrDefault(r => r.PPSNNO == model.PPSNNO && r.IsActive == true);
                if (isLandlordExit == null)
                {
                    LandlordRegistration reg = new LandlordRegistration();
                    reg.FirstName = model.FirstName;
                    reg.LastName = model.LastName;
                    reg.Email = model.Email;
                    reg.Password = model.Password;
                    reg.PPSNNO = model.PPSNNO;
                    reg.PhoneNo = model.PhoneNo;
                    reg.Address = model.Address;
                    reg.IsActive = true;
                    reg.CreatedDate = DateTime.Now.ToString();
                    dbContext.LandlordRegistrations.Add(reg);
                    int success = dbContext.SaveChanges();
                    if (success > 0)
                    {
                        return RedirectToAction("RegistrationSuccess", new { id = 1 });

                    }
                }
                else
                {
                    ModelState.AddModelError("", "Already registration completed with the same PPSNNO");

                }

            }

            return View(model);
        }