public IActionResult GetUserReportByMonth(ReportViewmodel reportViewmodel) { var reports = _reportService.GetReportsByUserId(reportViewmodel.UserId).ToArray(); var report = _reportControllerServices.GetReportByMonth(reportViewmodel, reports, _reportService); return(Ok(report)); }
public Report ReportViewModelToReport(ReportViewmodel model) { return(new Report { Id = model.Id, UserId = model.UserId, Accepted = model.Accepted, Attest = model.Attest, DeviationItems = model.DeviationItems, CreatedDate = DateTime.Now, UpdatedDate = DateTime.Now, Date = model.Date }); }
public IActionResult AttestOrApprovedChange(ReportViewmodel reportViewmodel) { var report = _reportService.GetReportById(reportViewmodel.Id); report.Attest = reportViewmodel.Attest; report.Accepted = reportViewmodel.Accepted; _reportService.Update(report); var updatedReportViewmodel = Mapper.ModelToViewModelMapping.ReportViewmodel(report); updatedReportViewmodel.FirstName = reportViewmodel.FirstName; updatedReportViewmodel.LastName = reportViewmodel.LastName; return(Ok(updatedReportViewmodel)); }
public IActionResult AddReport(ReportViewmodel reportViewmodel) { var report = _reportService.GetReportById(reportViewmodel.Id); if (report == null) { reportViewmodel.Date = _reportControllerServices.DateParser(reportViewmodel.CurrentMonth); report = Mapper.ViewModelToModelMapping.ReportViewModelToReport(reportViewmodel); _reportService.Add(report); return(Ok(report)); } else { var updatedReport = _reportControllerServices.UpdateReportDeviations(report, _deviationService, reportViewmodel); _reportService.Update(updatedReport); return(Ok(updatedReport)); } }
public Report GetReportByMonth(ReportViewmodel reportViewmodel, Report[] reports, IReportService _reportService) { DateTime currentMonthParsed = DateTime.Parse(reportViewmodel.CurrentMonth); var currentMonth = currentMonthParsed.ToString("yyyy-MM"); foreach (var report in reports) { var reportDate = report.Date.ToString("yyyy-MM"); if (reportDate == currentMonth) { _reportService.GetReportById(report.Id); var sortDeviations = report.DeviationItems.OrderByDescending(x => x.AbsenceDate); report.DeviationItems = sortDeviations.ToList(); return(report); } } return(Mapper.ViewModelToModelMapping.ReportViewModelToReport(reportViewmodel)); }
public Patient_history() { InitializeComponent(); BindingContext = new ReportViewmodel(); }
public Report UpdateReportDeviations(Report report, IDeviationService _deviationService, ReportViewmodel reportViewmodel) { foreach (var deviation in report.DeviationItems) { _deviationService.Remove(deviation); } report.DeviationItems = reportViewmodel.DeviationItems; report.UpdatedDate = DateTime.Now; return(report); }