Exemplo n.º 1
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));
        }
Exemplo n.º 2
0
        public static void AfterScenario()
        {
            foreach (var entity in _AddedEntities)
            {
                switch (entity.Type)
                {
                case (EntityType.Department):
                    var commandModel = new DepartmentDelete.CommandModel {
                        DepartmentID = (int)entity.Id
                    };
                    DomainServices.Dispatch(new DepartmentDelete.Request("test", commandModel));
                    break;

                case (EntityType.Student):
                    var commandModel1 = new StudentDelete.CommandModel {
                        StudentId = (int)entity.Id
                    };
                    DomainServices.Dispatch(new StudentDelete.Request("test", commandModel1));
                    break;

                case (EntityType.Instructor):
                    var commandModel2 = new InstructorDelete.CommandModel {
                        InstructorId = (int)entity.Id
                    };
                    DomainServices.Dispatch(new InstructorDelete.Request("test", commandModel2));
                    break;

                case (EntityType.Course):
                    var commandModel3 = new CourseDelete.CommandModel {
                        CourseId = (int)entity.Id
                    };
                    DomainServices.Dispatch(new CourseDelete.Request("test", commandModel3));
                    break;

                default:
                    throw new ApplicationException($"Missing entity removal for type {entity.Type}");
                }
            }
        }