public bool Update(WorkoutModel aModel) { bool result = false; //await Task.Run(() => //{ try { var getToUpdate = context.Workout.First(a => a.Id == aModel.Id); getToUpdate.Code = aModel.CodigoWorkout; getToUpdate.Name = aModel.Name; getToUpdate.Description = aModel.Description; getToUpdate.Active = aModel.Active; getToUpdate.Parent = aModel.Parent == 0 ? null : aModel.Parent; //aModel.Parent; getToUpdate.Color = aModel.Color; getToUpdate.DateUpdated = aModel.DateUpdated; context.Entry(getToUpdate).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return(true); } catch (Exception ex) { result = false; } //}); return(result); }
public bool Update(TrainerModel aModel) { bool result = false; //await Task.Run(() => //{ try { var getToUpdate = context.Trainer.First(a => a.Id == aModel.Id); //.GetById(aModel.Id); getToUpdate.Code = aModel.Code; getToUpdate.Name = aModel.Name; getToUpdate.Description = aModel.Description; getToUpdate.IdType = aModel.Type; getToUpdate.Active = aModel.Active; getToUpdate.DateUpdated = aModel.DateUpdated; getToUpdate.Finger1 = aModel.Huella1; getToUpdate.Finger2 = aModel.Huella2; getToUpdate.Price = aModel.Price; getToUpdate.PhotoLink = aModel.PhotoLink; context.Entry(getToUpdate).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return(true); } catch (Exception ex) { result = false; } //}); return(result); }