public static void Create(Entity.CMS_AccountLoginLog accountLoginLog) { using (var context = new Entity.OiWeb()) { context.CMS_AccountLoginLog.Add(accountLoginLog); context.SaveChanges(); } }
public async Task <ActionResult> LoginIsValid(LoginViewModel model) { if (ModelState.IsValid) { Entity.CMS_Account account = new Entity.CMS_Account(); Entity.CMS_AccountLoginLog accountLoginLog = new Entity.CMS_AccountLoginLog(); account.email = model.Email; account.password = model.Password; var user = Business.CMS_Account.IsValid(account); if (user != null) { if (model.returnUrl == null) { model.returnUrl = "Dashboard"; } #region Registra Acesso accountLoginLog.idAccount = user.idAccount; accountLoginLog.IsValid = true; accountLoginLog.dtRegister = DateTime.Now; Business.CMS_AccountLoginLog.Create(accountLoginLog); #endregion Session.Add("User", user); Response.Redirect("/Grupos"); } else { #region Registra Acesso Falho account = Business.CMS_Account.IsValidEmail(account); if (account != null) { accountLoginLog.idAccount = account.idAccount; accountLoginLog.IsValid = false; accountLoginLog.dtRegister = DateTime.Now; Business.CMS_AccountLoginLog.Create(accountLoginLog); } #endregion ViewBag.Error = "has-error"; return(View("/Views/Account/Login.cshtml", model)); } } ViewBag.Error = "has-error"; return(View("/Views/Account/Login.cshtml", model)); }