public int Create(TimeReportServiceModel timeReportModel) { TimeReportDbModel timeReport = timeReportEntityConverter.Convert(timeReportModel); dbContext.Add(timeReport); dbContext.SaveChanges(); return(timeReport.Id); }
public TimeReportDto Convert(TimeReportServiceModel source) { var timeReportDto = new TimeReportDto { StartTime = source.StartTime.ToShortTimeString(), EndTime = source.EndTime.ToShortTimeString(), Deduction = source.Deduction.ToString(), Balance = source.Balance.ToString(), FinalBalance = source.FinalBalance.ToString() }; return(timeReportDto); }
public TimeReportDbModel Convert(TimeReportServiceModel source) { return(source != null ? new TimeReportDbModel { Id = source.Id, RecordId = source.RecordId, StartTime = source.StartTime, EndTime = source.EndTime, Deduction = source.Deduction, Balance = source.Balance, FinalBalance = source.FinalBalance } : null); }
public TimeReportServiceModel Convert(TimeReportDto source) { var timeReportServiceModel = new TimeReportServiceModel { RecordId = recordIdParser.ParseRecordId(DateTime.Parse(source.StartTime)), StartTime = DateTime.Parse(source.StartTime), EndTime = DateTime.Parse(source.EndTime), Deduction = TimeSpan.Parse(source.Deduction) }; timeReportServiceModel.Balance = timeReportServiceModel.EndTime .Subtract(timeReportServiceModel.StartTime) .Subtract(timeReportServiceModel.Deduction); timeReportServiceModel.FinalBalance = timeReportServiceModel.FinalBalance.Add(timeReportServiceModel.Balance); return(timeReportServiceModel); }