public async Task <User> LoginAsync() { IsBusy = true; var user = await _identityService.LoginAsync(_userName, _password); if (user == null) { IsBusy = false; ValidateProperty(() => true, Constants.Messages.LoginError); return(null); } if (!user.SessionActive) { _sessionService.AddToSession("logged", "true"); if (user.UserType == Enumerations.UserType.Technician) { _sessionService.AddToSession("technician", "true"); } } else { ValidateProperty(() => true, Constants.Messages.HasLoggedSomewhereElse); } IsBusy = false; return(user); }
public ActionResult Uod(UodModel model) { if (ModelState.IsValid) { UodSummary uodSummary = _calcService.CalculateIncome(model.BruttoAmountPerMonth, model.Limit); model.CurrentSummary = _mapper.Map <UodSummaryModel>(uodSummary); var summariesFromSession = _sessionService.GetFromSession <List <UodSummaryModel> >(SessionItem.Uod); if (summariesFromSession == null) { summariesFromSession = new List <UodSummaryModel>() { model.CurrentSummary }; _sessionService.AddToSession(SessionItem.Uod, summariesFromSession); } else if (!summariesFromSession.Exists(x => Convert.ToDecimal(x.Brutto) == model.BruttoAmountPerMonth)) { summariesFromSession.Add(model.CurrentSummary); } model.SavedSummaries = summariesFromSession; return(View(model)); } else { return(RedirectToAction(nameof(Uod))); } }
public ActionResult Login(LoginModel model, string returnUrl) { if (!ModelState.IsValid) { return(View(model)); } UserResult loginResult = _userSrv.AuthenticateUser(model.Login, model.Password); if (loginResult.IsOK) { _sessionSrv.AddToSession(SessionItem.User, loginResult.User); FormsAuthentication.SetAuthCookie(model.Login, false); return(RedirectToLocal(returnUrl)); } else { ModelState.AddModelError("", loginResult.Message); } return(View(model)); }