/// <summary> /// Maps a DiveLogRecord instance to a DiveLogEntryDto instance /// </summary> private static DiveLogEntryDto MapToDiveLogEntryDto(DiveLogRecord r) { return(new DiveLogEntryDto { Id = r.Id, Date = r.Date, DiveSite = r.DiveSite, Location = r.Location, MaxDepth = r.MaxDepth, BottomTime = r.BottomTime, Comment = r.Comment }); }
/// <summary> /// Registers a new dive log entry /// </summary> /// <param name="dive">The dive log entry to save</param> public async Task <int> RegisterDiveLogEntryAsync(DiveLogEntryDto dive) { ValidateDiveLogArgument(dive); Verify.Require(dive.Id == 0, "dive.Id"); Verify.RaiseWhenFailed(); using (var ctx = DataAccessFactory.CreateContext <IDiveLogDataAccessOperations>()) { var diveRecord = new DiveLogRecord { UserId = ServicedUserId, Date = dive.Date, DiveSite = dive.DiveSite, Location = dive.Location, MaxDepth = dive.MaxDepth, BottomTime = dive.BottomTime, Comment = dive.Comment }; await ctx.InsertDiveLogEntryAsync(diveRecord); return(diveRecord.Id); } }