예제 #1
0
        public async Task <IActionResult> Create([FromForm] VisitViewModel visitVm)
        {
            if (ModelState.IsValid)
            {
                visitVm.VisitTypes       = default;
                visitVm.Employees        = default;
                visitVm.Offices          = default;
                visitVm.RegisterControls = default;
                visitVm.VisitStates      = default;

                //visitVm.VisitPersons = default;


                var newVisit = await _visitRepo.AddVisit(visitVm.Visit);

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

                //return RedirectToAction(nameof(Index));

                return(RedirectToAction(nameof(Edit), new { id = newVisit.Id, returnUrl = visitVm.ReturnUrl }));
            }

            TempData["message"]     = "A problem has been ocurred while submitting your data.";
            TempData["toasterType"] = ToasterType.info;

            return(View("Edit", VisitViewModelFactory.Create(visitVm.Visit, visitVm.ReturnUrl,
                                                             VisitTypes,
                                                             Employees,
                                                             Offices,
                                                             RegisterControls,
                                                             VisitStates)));
        }
예제 #2
0
        public IActionResult Create(string returnUrl)
        {
            if (String.IsNullOrEmpty(returnUrl))
            {
                returnUrl = Request.Headers["Referer"].ToString();
            }

            return(View("Edit", VisitViewModelFactory.Create(new VisitDto(), returnUrl,
                                                             VisitTypes,
                                                             Employees,
                                                             Offices,
                                                             RegisterControls,
                                                             VisitStates)));
        }