示例#1
0
        public IActionResult GetUserReportByMonth(ReportViewmodel reportViewmodel)
        {
            var reports = _reportService.GetReportsByUserId(reportViewmodel.UserId).ToArray();

            var report = _reportControllerServices.GetReportByMonth(reportViewmodel, reports, _reportService);

            return(Ok(report));
        }
示例#2
0
 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
     });
 }
示例#3
0
        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));
        }
示例#4
0
        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));
            }
        }
示例#5
0
        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));
        }
示例#6
0
 public Patient_history()
 {
     InitializeComponent();
     BindingContext = new ReportViewmodel();
 }
示例#7
0
        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);
        }