/// <summary> /// Delets the object after the confirmation. /// </summary> /// <param name="id">The ID of the object to delete</param> /// <param name="actionName">The name of the action to call after success deletion</param> /// <param name="controllerName">The name of the controller of the action to call after success deletion</param> /// <param name="message">The message ti display after deletion</param> /// <returns>The validation summary if the deletion is not possible or appropriate refreshed view</returns> public virtual ActionResult DoDeleteConfirmed(AfterDeleteParam afterDeleteParam) { try { GetUnitOfWork().StartTransaction(); GetService().Delete(afterDeleteParam.DeletionDto); GetUnitOfWork().EndTransaction(); GetTempDataManager().SetTempData(TempDataConstants.MESSAGE, afterDeleteParam.Message); } catch (ValidationException ex) { return(RedirectToActionAfterFailDelete(AfterFailSaveParam.Create(ex.GetValidationResults()))); } return(RedirectToActionAfterSuccessDelete(afterDeleteParam)); }
/// <summary> /// Calls the appropriate service and persists the DTO to the database. /// </summary> /// <param name="dto">The DTO to persist</param> /// <param name="message">The message to display to user after the operation is finished</param> /// <param name="actionName">The name of the action</param> /// <param name="controllerName">The name of the controller</param> /// <param name="routeValues">The route values for redirect</param> /// <returns>The apropriate View</returns> public virtual ActionResult DoCreate(T dto, AfterSuccessSaveParam afterSuccessSaveParam) { if (!ModelState.IsValid) { return(RedirectToActionAfterClientFailCreate(dto, null)); } try { GetUnitOfWork().StartTransaction(); dto = GetService().Persist(dto); GetUnitOfWork().EndTransaction(); afterSuccessSaveParam.Id = dto.Id; GetTempDataManager().SetTempData(TempDataConstants.MESSAGE, afterSuccessSaveParam.Message); GetTempDataManager().SetTempData(TempDataConstants.DTO, dto); } catch (ValidationException ex) { return(RedirectToActionAfterServerFailCreate(dto, AfterFailSaveParam.Create(ex.GetValidationResults()))); } return(RedirectToActionAfterSuccessCreate(afterSuccessSaveParam)); }