public ActionResult Update(string street, int postalCode, string unitNo, string surname, string contactNo, string email) { _session = Session.getInstance; Household householduser = (Household)_session.GetUser(); householduser.Street = street; householduser.PostalCode = postalCode; householduser.UnitNo = unitNo; householduser.Surname = surname; householduser.ContactNo = contactNo; householduser.Email = email; new HouseholdMapper().Update(householduser).Save().Commit(); appLogCreator.AddLog(this, "ACTION*/-UPDATEPROFILE", DateTime.Now); return(View(nameof(Profile), householduser)); }
public IActionResult Login([FromServices] IAppLogCreator appLogCreator, [FromServices] IAppLogRetriever appLogRetriever, String username, String password) { IUser user = UserTypeFactory.CreateUser(username, password); if (user != null && user.GetType() == typeof(Administrator)) { Administrator AdminUser = (Administrator)user; AdminUser.IsLogin = true; _session = Session.getInstance; _session.setCurrentUser(AdminUser); new AdminMapper().Update(AdminUser).Save().Commit(); return(RedirectToAction("Profile", "Admin")); } else if (user != null && user.GetType() == typeof(Household)) { Household householduser = (Household)user; householduser.IsLogin = true; _session = Session.getInstance; _session.setCurrentUser(householduser); new HouseholdMapper().Update(householduser).Save().Commit(); appLogRetriever.SetHouseholdId(householduser._id); appLogCreator.SetHouseholdId(householduser._id); appLogCreator.AddLog(this, "ACTION*/-LOGIN", DateTime.Now); return(RedirectToAction("Profile", "Household")); } else { return(View("Index")); } }
public ActionResult Profile([FromServices] IAppLogCreator appLogCreator) { _session = Session.getInstance; if (_session.GetUser().GetType() == typeof(Household)) { if (_session.isFromLogin()) //Do not count initial profile "Visit" upon login { Console.WriteLine("Redirect to profile page from login"); } else { appLogCreator.AddLog(this, "PAGE*/-View-Profile", DateTime.Now); } return(View((Household)_session.GetUser())); } else if (_session.IsLogin() == true && _session.GetUser().GetType() == typeof(Administrator)) { return(View(_session.GetUser())); } return(RedirectToAction("Index", "Home")); }