public async Task <IActionResult> AddTransaction(Transaction model) { //Add new Transacction List <Alert> lstAlerts = new List <Alert>(); if (ModelState.IsValid) { model.User = await _userManager.GetUserAsync(User); if (_homeBusiness.AddTrasaction(model)) { lstAlerts.Add(new Alert("success", "Transacción registrada correctamente.")); } } else { foreach (var error in ModelState.Values.Where(x => x.Errors.Count > 0)) { foreach (var msg in error.Errors) { lstAlerts.Add(new Alert("warning", msg.ErrorMessage)); } } } var tempAlerts = JsonConvert.SerializeObject(lstAlerts.ToList()); TempData[SessionKeys.Alerts] = tempAlerts; return(RedirectToAction("Index")); }