/// <summary> /// Finds a specific physiology record and adds and adjusts relating properties for display /// </summary> /// <param name="phyId">The identifier for a physiology record</param> /// <returns>The specified physiology dto model</returns> public PhysiologyDto FindPhysiologyRecord(int phyId) { Physiology physiology = db.Physiologies.Find(phyId); PhysiologyDto model = new PhysiologyDto() { Height = physiology.Height, Weight = physiology.Weight, Date = physiology.Date, IsLosing = physiology.IsLosing, PhyId = phyId, Comment = physiology.Comment, AgeSnapshot = physiology.AgeSnapshot, UserId = (from u in this.db.User_Phy where u.PhyId == phyId select u.UserId).FirstOrDefault(), }; if (model.Comment == null) { model.Comment = ""; } ConvertToFeetAndInches(model); return(model); }
/// <summary> /// Transfers physiology dto model data into the domain model /// </summary> /// <param name="physiology">The physiology dto model</param> /// <returns>The physiology domain model</returns> private Physiology PhysiologyToDomain(PhysiologyDto physiology) { var phy = new Physiology { Height = ConvertToCentimeters(physiology), Weight = physiology.Weight, IsLosing = physiology.IsLosing, Date = physiology.Date, PhyId = physiology.PhyId, Comment = physiology.Comment, AgeSnapshot = physiology.AgeSnapshot }; return(phy); }
/// <summary> /// Deletes/Removes a specific physiology record /// </summary> /// <param name="phyId">The identifier to a physiology record</param> /// <returns>The boolean value determining if the record was found for deletion or not</returns> public bool Delete(int phyId) { Physiology physiology = db.Physiologies.Find(phyId); if (physiology != null) { var userPhy = (from x in this.db.User_Phy where x.PhyId == phyId select x).Single(); if (userPhy != null) { db.Physiologies.Remove(physiology); db.User_Phy.Remove(userPhy); db.SaveChanges(); return(true); } } return(false); }