コード例 #1
0
        public async Task <IActionResult> Edit([FromForm] VisitViewModel visitVM)
        {
            if (ModelState.IsValid)
            {
                await _visitRepo.UpdateVisit(visitVM.Visit);

                TempData["message"]     = "Your data has been updated successfully.";
                TempData["toasterType"] = ToasterType.success;

                return(RedirectToAction(nameof(Edit), new { id = visitVM.Visit.Id, returnUrl = visitVM.ReturnUrl }));
            }
            else
            {
                TempData["message"]     = "A problem has been ocurred while updating your data.";
                TempData["toasterType"] = ToasterType.info;
            }

            VisitPersons = GetVisitPersons(visitVM.Visit.Id);

            return(View("Edit", VisitViewModelFactory.Edit(visitVM.Visit, visitVM.ReturnUrl,
                                                           VisitTypes,
                                                           Employees,
                                                           Offices,
                                                           RegisterControls,
                                                           VisitStates,
                                                           VisitPersons)));
        }
コード例 #2
0
        public async Task <IActionResult> Edit(int id, string returnUrl = null)
        {
            if (String.IsNullOrEmpty(returnUrl))
            {
                returnUrl = Request.Headers["Referer"].ToString();
            }

            var visit = await _visitRepo.GetVisit(id);

            VisitPersons = GetVisitPersons(id);

            VisitViewModel visitVm = VisitViewModelFactory.Edit(visit, returnUrl,
                                                                VisitTypes,
                                                                Employees,
                                                                Offices,
                                                                RegisterControls,
                                                                VisitStates,
                                                                VisitPersons);

            return(View("Edit", visitVm));
        }