public async Task <Producto> Upsert(Producto producto) { producto.Activo = true; if (producto.Id == 0) { //hardcoded until login// producto.IdUserAlta = 1; producto.FechaAlta = DateTime.Now; producto.Activo = true; _context.Add(producto); } else { //hardcoded until login// producto.IdUserModif = 1; //Not verifying if there was any changes producto.FechaModif = DateTime.Now; try { _context.Update(producto); } catch (DbUpdateConcurrencyException) { throw; } } await _context.SaveChangesAsync(); return(producto); }
public async Task <IActionResult> Create([Bind("Id,Nombre,Apellido,Email,Password,IdUserAlta,IdUserModif,IdUserBaja,FechaAlta,FechaModif,FechaBaja,Activo,AlertaPedidoEnCamino,AlertaHabilitaPedido,MismoUltimoPedido")] Cliente cliente) { if (ModelState.IsValid) { _context.Add(cliente); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(cliente)); }
public async Task <IActionResult> Create([Bind("Name,LastName,DocumentNumber,PhoneNumber,UserToken,CreationDate,BirthDate,IsDeleted,Id,Password,Email,EmailConfirmed,Active")] User user) { if (ModelState.IsValid) { _context.Add(user); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(user)); }