public async Task <Producto> Add(Producto entity) { context.Entry(entity).State = EntityState.Added; await context.SaveChangesAsync(); return(entity); }
public async Task <bool> CreateOrUpdateProducto(Productos model) { var success = false; try { if (model.IdProducto > 0) { context.Entry(model).State = System.Data.Entity.EntityState.Modified; } else { context.Entry(model).State = System.Data.Entity.EntityState.Added; } await context.SaveChangesAsync(); success = true; } catch { } return(success); }
public async Task <bool> AgregarAlCarrito(int IdUser, int IdProducto) { bool success = false; try { var model = new CarritoCompras() { IdProducto = IdProducto, IdUsuario = IdUser, FechaAgregado = DateTime.Now }; context.Entry(model).State = EntityState.Added; await context.SaveChangesAsync(); success = true; } catch { } return(success); }
public async Task <bool> UserDelete(int?id) { try { UserInfo info = context.UserInfo.Find(id); Usuarios usu = context.usuarios.Find(id); context.UserInfo.Remove(info); await context.SaveChangesAsync(); context.usuarios.Remove(usu); await context.SaveChangesAsync(); return(true); } catch (Exception) { return(false); } }