コード例 #1
0
ファイル: TimeReportRepository.cs プロジェクト: san-had/tirep
        public int Create(TimeReportServiceModel timeReportModel)
        {
            TimeReportDbModel timeReport = timeReportEntityConverter.Convert(timeReportModel);

            dbContext.Add(timeReport);
            dbContext.SaveChanges();
            return(timeReport.Id);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
 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);
 }
コード例 #4
0
        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);
        }