public async Task <ActionResult> DeleteConfirmed(int id)
        {
            var request = new InstructorDelete.Request(
                SystemPrincipal.Name,
                new InstructorDelete.CommandModel {
                InstructorId = id
            });

            await DomainServices.DispatchAsync(request);

            return(RedirectToAction("Index"));
        }
Beispiel #2
0
        public async Task <ActionResult> Create(DepartmentCreate.CommandModel commandModel)
        {
            var request  = new DepartmentCreate.Request(SystemPrincipal.Name, commandModel);
            var response = await DomainServices.DispatchAsync <DepartmentCreate.Response>(request);

            if (!response.HasValidationIssues)
            {
                return(RedirectToAction("Index"));
            }

            var instructors = await _QueryRepository.GetEntitiesAsync <Instructor>(new AsNoTrackingQueryStrategy());;

            ViewBag.InstructorID = new SelectList(instructors, "ID", "FullName", commandModel.InstructorID);

            ModelState.AddRange(response.ValidationDetails);
            return(View(commandModel));
        }
Beispiel #3
0
        public async Task <ActionResult> Delete(DepartmentDelete.CommandModel commandModel)
        {
            var request  = new DepartmentDelete.Request(SystemPrincipal.Name, commandModel);
            var response = await DomainServices.DispatchAsync <DepartmentDelete.Response>(request);

            if (!response.HasValidationIssues)
            {
                return(RedirectToAction("Index"));
            }

            if (response.HasConcurrencyError.Value)
            {
                RedirectToAction("Delete", new { concurrencyError = true, id = commandModel.DepartmentID });
            }

            ModelState.AddModelError(string.Empty, "Unable to delete. Try again, and if the problem persists contact your system administrator.");
            return(View(commandModel));
        }