private static PersonAntroModel GetPersonAntroModel(PersonAntro antroEntity) { return(antroEntity != null ? new PersonAntroModel { Id = antroEntity.Id, IdPerson = antroEntity.id_Person, IdAntro = antroEntity.id_Antro, Value = antroEntity.Value, AntroName = antroEntity.AntroName.Name } : new PersonAntroModel()); }
/// <see cref="IPersonRepository.UpdatePersonAntro" /> public PersonAntro UpdatePersonAntro(PersonAntro property, int userId) { if (property.Id == 0) { db.Entry(property).State = System.Data.Entity.EntityState.Added; } else if (property.Id > 0) { var pr = db.PersonAntro.FirstOrDefault(o => o.Id == property.Id); SaveLog(pr, property, property.id_Person, userId, LogType.Anthropometry); db.Entry(pr).CurrentValues.SetValues(property); } try { db.SaveChanges(); } catch (Exception e) { return(null); } return(property); }
/// <see cref="IPersonRepository.AddPersonAntros(PersonAntro, int)" /> public int AddPersonAntros(PersonAntro property, int userId) { var res = UpdatePersonAntro(property, userId); return(res?.Id ?? -1); }