public ActionResult Delete(Guid id) { DeleteSolution command = new DeleteSolution(id); return Validating(command, () => { _service.Execute(command); return RedirectToAction("List"); }); }
private void deleteHandlingAssignedModels(DeleteSolution cmd) { Presentation.Models.DefectHandling.Issue[] relatedIssues = _models.Query<Presentation.Models.DefectHandling.Issue>() .Where(i => i.Solution.Id == cmd.Id.ToString()) .ToArray(); Array.ForEach(relatedIssues, i => _models.Delete(i)); }
private void deleteSupportEntity(DeleteSolution cmd) { var entities = _models.Single<Presentation.Models.DefectHandling.SupportEntities>( Presentation.Models.DefectHandling.SupportEntities.TheId); var toBeDeleted = entities.Solutions.Single(s => s.Id.Equals(cmd.Id.ToString(), StringComparison.Ordinal)); entities.Solutions.Remove(toBeDeleted); }
private void deleteHandlingAssignedSnapshot(DeleteSolution cmd) { _snapshots.Delete<Domain.DefectHandling.Issue>(i => i.Solution.Id == cmd.Id); }
private void deleteHandlingSnapshot(DeleteSolution cmd) { _snapshots.Delete<Domain.DefectHandling.Solution>(s => s.Id.Equals(cmd.Id)); }
private void deleteAssignedModels(DeleteSolution cmd) { Presentation.Models.Admin.AppVersion[] assignedVersions = _models.Query<Presentation.Models.Admin.AppVersion, Queries.VersionsAssignedToSolution>() .Where(v => v.AssignedTo.Id == cmd.Id.ToString()) .ToArray(); Array.ForEach(assignedVersions, version => version.AssignedTo = null); Presentation.Models.Admin.Build[] assignedBuilds = _models.Query<Presentation.Models.Admin.Build, Queries.BuildsAssignedToSolution>() .Where(v => v.AssignedTo.Id == cmd.Id.ToString()) .ToArray(); Array.ForEach(assignedBuilds, build => build.AssignedTo = null); }
private void deleteModel(DeleteSolution cmd) { var toBeDeleted = _models.Single<Presentation.Models.Admin.Solution>(cmd.Id); _models.Delete(toBeDeleted); }
private void deleteSnapshot(DeleteSolution cmd) { _snapshots.Delete<Solution>(s => s.Id == cmd.Id); }
public void Execute(DeleteSolution command) { _validation.AssertValidity(command); try { deleteSnapshot(command); deleteModel(command); deleteAssignedModels(command); // another bounded context (DefectHandling) deleteHandlingSnapshot(command); deleteHandlingAssignedSnapshot(command); deleteSupportEntity(command); deleteHandlingAssignedModels(command); _models.SaveChanges(); } catch (Exception) { _snapshots.RollbackChanges(); throw; } }