示例#1
0
        public ActionResult Add(ExpansViewModels model)
        {
            if (!ExpanseReportService.CheckDay(model))
            {
                ModelState.AddModelError("Day", "Ce jour ne fait pas parti de ce mois");
            }

            if (Service.CheckAmount(model) > 0)
            {
                ModelState.AddModelError("Amount_HT", "Vous avez dépassez le plafond pour ce frais de " + Service.CheckAmount(model) + "€");
            }


            if (ModelState.IsValid)
            {
                Service.Add(model);
                ExpanseReportService.UpdateAmount(model.ExpanseReport_ID);
            }

            ExpanseReportViewModels report = ExpanseReportService.GetById(model.ExpanseReport_ID);

            ViewBag.Days = new SelectList(report.Days);

            return(PartialView("_FormCreateExpanse", model));
        }
        public ActionResult Details(string id, ExpanseReportViewModels model = null)
        {
            ExpanseReportViewModels report = Service.GetById(id);

            if (report != null)
            {
                ViewBag.Days = new SelectList(report.Days);
                return(View(report));
            }

            return(new HttpStatusCodeResult(404));
        }