Ejemplo n.º 1
0
 /// <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));
 }
Ejemplo n.º 2
0
        /// <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));
        }
Ejemplo n.º 3
0
 protected override ActionResult RedirectToActionAfterServerFailCreate(T dto, AfterFailSaveParam afterFailSaveParam)
 {
     return(Json(JsonDialogResult.CreateFail(HtmlConstants.DIALOG_VALIDATION_SUMMARY, afterFailSaveParam.ValidationMessage)));
 }
Ejemplo n.º 4
0
 protected override ActionResult RedirectToActionAfterClientFailCreate(T dto, AfterFailSaveParam afterFailSaveParam)
 {
     return(Json(JsonDialogResult.CreateFail(HtmlConstants.DIALOG_VALIDATION_SUMMARY, ValidationSummaryExtensions.CustomValidationSummary(ModelState).ToString())));
 }
Ejemplo n.º 5
0
 protected virtual ActionResult RedirectToActionAfterClientFailCreate(T dto, AfterFailSaveParam afterFailSaveParam)
 {
     return(View(dto));
 }
Ejemplo n.º 6
0
 protected virtual ActionResult RedirectToActionAfterFailDelete(AfterFailSaveParam afterFailSaveParam)
 {
     return(Json(JsonDialogResult.CreateFail(HtmlConstants.DIALOG_VALIDATION_SUMMARY, ValidationSummaryExtensions.CustomValidationSummary(afterFailSaveParam.ValidationMessage).ToString())));
 }
Ejemplo n.º 7
0
 protected virtual ActionResult RedirectToActionAfterServerFailCreate(T dto, AfterFailSaveParam afterFailSaveParam)
 {
     ModelState.AddModelError(TempDataConstants.SERVER_VALIDATION_ERROR, afterFailSaveParam.ValidationMessage);
     return(View(dto));
 }