Exemple #1
0
        public async Task <IActionResult> Details(int id)
        {
            var returnUrl = Request.Headers["Referer"].ToString();

            var visitType = await _visitTypeRepo.GetVisitType(id);

            VisitTypeViewModel companyVM = VisitTypeViewModelFactory.Details(visitType, returnUrl);

            return(View("Edit", companyVM));
        }
Exemple #2
0
        public async Task <IActionResult> Delete(VisitTypeViewModel visitTypeVM)
        {
            await _visitTypeRepo.DeleteVisitType(visitTypeVM.VisitType);

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

            //return RedirectToAction(nameof(Index));

            return(Redirect(visitTypeVM.ReturnUrl));
        }
Exemple #3
0
        public async Task <IActionResult> Edit(int id, string returnUrl = null)
        {
            if (String.IsNullOrEmpty(returnUrl))
            {
                returnUrl = Request.Headers["Referer"].ToString();
            }

            var visitType = await _visitTypeRepo.GetVisitType(id);

            VisitTypeViewModel visitTypeVM = VisitTypeViewModelFactory.Edit(visitType, returnUrl);

            return(View("Edit", visitTypeVM));
        }
Exemple #4
0
        public async Task <IActionResult> Edit([FromForm] VisitTypeViewModel visitTypeVM)
        {
            if (ModelState.IsValid)
            {
                await _visitTypeRepo.UpdateVisitType(visitTypeVM.VisitType);

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

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

            return(View("Edit", VisitTypeViewModelFactory.Edit(visitTypeVM.VisitType, visitTypeVM.ReturnUrl)));
        }
Exemple #5
0
        public async Task <IActionResult> Create([FromForm] VisitTypeViewModel visitTypeVM)
        {
            if (ModelState.IsValid)
            {
                var newVisitType = await _visitTypeRepo.AddVisitType(visitTypeVM.VisitType);

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

                //return RedirectToAction(nameof(Index));

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

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

            return(View("Edit", VisitTypeViewModelFactory.Create(visitTypeVM.VisitType, visitTypeVM.ReturnUrl)));
        }