//[ValidateAntiForgeryToken] public async Task <ActionResult> LogOff(CortesCajero model) { if (model == null) { AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie); return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } using (var db = new AppDbContext()) { var corte = await db.CortesCajeros.FindAsync(model.Id); if (corte == null) { return(HttpNotFound()); } var detalles = await db.OperacionesCajeros.Where(x => x.CorteId == corte.Id).ToListAsync(); double?monto = 0.0d; if (detalles != null) { foreach (var item in detalles) { if (item.Monto != null) { monto += double.Parse(item.Monto.ToString(), new NumberFormatInfo { NumberDecimalSeparator = ".", NumberGroupSeparator = "," }); } if (item.CobroTag != null) { monto += double.Parse(item.CobroTag.ToString(), new NumberFormatInfo { NumberDecimalSeparator = ".", NumberGroupSeparator = "," }); } } corte.Comentario = model.Comentario; corte.DateTCierre = DateTime.Now; corte.MontoTotal = Math.Round(monto.Value, 2); if (ModelState.IsValid) { db.Entry(corte).State = EntityState.Modified; await db.SaveChangesAsync(); AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie); return(RedirectToAction("ReporteCajero", "Home", new { id = corte.Id })); } } AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie); var login = new LoginViewModel(); return(View("Login", login)); } }
public async Task <ActionResult> LogOff(int?id) { LoginViewModel login = null; if (id == null) { AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie); login = new LoginViewModel(); return(View("Login", login)); } var db = new AppDbContext(); CortesCajero corte = await db.CortesCajeros.FindAsync(id); if (corte == null) { return(HttpNotFound()); } AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie); ViewBag.Corte = corte; ViewBag.Exist = true; login = new LoginViewModel(); return(View("Login", login)); }