/// <summary> /// Convert TimeTrialResult Entity into TimeTrialResult Object /// </summary> ///<param name="model">TimeTrialResultViewModel</param> ///<param name="TimeTrialResultEntity">DataAccess.TimeTrialResult</param> ///<returns>TimeTrialResultViewModel</returns> public static TimeTrialResultViewModel ToViewModel( this DataAccess.TimeTrialResult entity, TimeTrialResultViewModel model) { model.Id = entity.Id; model.TimeTrialDistanceId = entity.TimeTrialDistanceId; model.TimeTaken = entity.TimeTaken ?? TimeSpan.MinValue; model.AveragePace = entity.AveragePace ?? TimeSpan.MinValue; model.MemberId = entity.MemberId; model.IsActive = entity.IsActive; return(model); }
/// <summary> /// Convert TimeTrialResult Object into TimeTrialResult Entity /// </summary> ///<param name="model">TimeTrialResult</param> ///<param name="TimeTrialResultEntity">DataAccess.TimeTrialResult</param> ///<returns>DataAccess.TimeTrialResult</returns> public static DataAccess.TimeTrialResult ToEntity(this TimeTrialResultViewModel model, DataAccess.TimeTrialResult entity) { if (entity.Id == 0) { entity.CreatedUserId = model.SessionUserId; entity.IsActive = model.IsActive; } else { entity.UpdatedUserId = model.SessionUserId; entity.UpdatedTimestamp = DateTime.Now; } entity.TimeTrialDistanceId = model.TimeTrialDistanceId; entity.TimeTaken = model.TimeTaken; entity.MemberId = model.MemberId; entity.Position = model.Position; return(entity); }