Beispiel #1
0
        public ActionResult Index([DataSourceRequest(Prefix = "Grid")] DataSourceRequest dsRequest)
        {
            if (!ViewBag.HasAccessToAdminModule)
            {
                WebHelper.CurrentSession.Content.ErrorMessage = "You are not eligible to do this action";
                return(RedirectToAction(Constants.Actions.AccessDenied, Constants.Controllers.Home, new { Area = String.Empty }));
            }
            CaseGoalDetailTemplate CaseGoalDetailTemplate = new CaseGoalDetailTemplate();

            return(View(CaseGoalDetailTemplate));
        }
Beispiel #2
0
        public ActionResult DeleteAjax(int id)
        {
            if (!ViewBag.HasAccessToAdminModule)
            {
                BaseModel baseModel = new BaseModel();
                baseModel.ErrorMessage = "You are not eligible to do this action";
                return(Json(new { success = false, data = this.RenderPartialViewToString(Constants.PartialViews.AlertSliding, baseModel) }, JsonRequestBehavior.AllowGet));
            }
            //find the CaseGoalDetailTemplate in database
            CaseGoalDetailTemplate CaseGoalDetailTemplate = CaseGoalDetailTemplateRepository.Find(id);

            if (CaseGoalDetailTemplate == null)
            {
                //set error message if it does not exist in database
                CaseGoalDetailTemplate = new CaseGoalDetailTemplate();
                CaseGoalDetailTemplate.ErrorMessage = "Template not found";
            }
            else
            {
                try
                {
                    //delete CaseGoalDetailTemplate from database
                    CaseGoalDetailTemplateRepository.Delete(CaseGoalDetailTemplate);
                    CaseGoalDetailTemplateRepository.Save();
                    //set success message
                    CaseGoalDetailTemplate.SuccessMessage = "Template has been deleted successfully";
                }
                catch (CustomException ex)
                {
                    CaseGoalDetailTemplate.ErrorMessage = ex.UserDefinedMessage;
                }
                catch (Exception ex)
                {
                    ExceptionManager.Manage(ex);
                    CaseGoalDetailTemplate.ErrorMessage = Constants.Messages.UnhandelledError;
                }
            }
            //return action status in json to display on a message bar
            if (CaseGoalDetailTemplate.ErrorMessage.IsNotNullOrEmpty())
            {
                return(Json(new { success = false, data = this.RenderPartialViewToString(Constants.PartialViews.AlertSliding, CaseGoalDetailTemplate) }));
            }
            else
            {
                return(Json(new { success = true, data = this.RenderPartialViewToString(Constants.PartialViews.AlertSliding, CaseGoalDetailTemplate) }));
            }
        }
Beispiel #3
0
        public ActionResult EditorAjax(int id)
        {
            CaseGoalDetailTemplate CaseGoalDetailTemplate = null;

            if (id > 0)
            {
                //find an existing CaseGoalDetailTemplate from database
                CaseGoalDetailTemplate = CaseGoalDetailTemplateRepository.Find(id);
                if (CaseGoalDetailTemplate == null)
                {
                    //throw an exception if id is provided but data does not exist in database
                    return(new HttpStatusCodeResult(System.Net.HttpStatusCode.NotFound, "Template not found"));
                }
            }
            else
            {
                //create a new instance if id is not provided
                CaseGoalDetailTemplate = new CaseGoalDetailTemplate();
            }

            //return the html of editor to display on popup
            return(Content(this.RenderPartialViewToString(Constants.PartialViews.CreateOrEdit, CaseGoalDetailTemplate)));
        }
Beispiel #4
0
        public ActionResult SaveAjax(CaseGoalDetailTemplate CaseGoalDetailTemplate)
        {
            //id=0 means add operation, update operation otherwise
            bool isNew = CaseGoalDetailTemplate.ID == 0;

            CaseGoalDetailTemplate.CreatedByWorkerID     = CurrentLoggedInWorker.ID;
            CaseGoalDetailTemplate.LastUpdatedByWorkerID = CurrentLoggedInWorker.ID;
            //validate data
            if (ModelState.IsValid)
            {
                try
                {
                    //call repository function to save the data in database
                    CaseGoalDetailTemplate.Name        = CaseGoalDetailTemplate.Name == null ? string.Empty : CaseGoalDetailTemplate.Name;
                    CaseGoalDetailTemplate.Description = CaseGoalDetailTemplate.Description == null ? string.Empty : CaseGoalDetailTemplate.Description;

                    CaseGoalDetailTemplateRepository.InsertOrUpdate(CaseGoalDetailTemplate);
                    CaseGoalDetailTemplateRepository.Save();
                    //set status message
                    if (isNew)
                    {
                        CaseGoalDetailTemplate.SuccessMessage = "Template added successfully";
                    }
                    else
                    {
                        CaseGoalDetailTemplate.SuccessMessage = "Template modified successfully";
                    }
                }
                catch (CustomException ex)
                {
                    CaseGoalDetailTemplate.ErrorMessage = ex.UserDefinedMessage;
                }
                catch (Exception ex)
                {
                    ExceptionManager.Manage(ex);
                    CaseGoalDetailTemplate.ErrorMessage = Constants.Messages.UnhandelledError;
                }
            }
            else
            {
                foreach (var modelStateValue in ViewData.ModelState.Values)
                {
                    foreach (var error in modelStateValue.Errors)
                    {
                        CaseGoalDetailTemplate.ErrorMessage = error.ErrorMessage;
                        break;
                    }
                    if (CaseGoalDetailTemplate.ErrorMessage.IsNotNullOrEmpty())
                    {
                        break;
                    }
                }
            }
            //return the status message in json
            if (CaseGoalDetailTemplate.ErrorMessage.IsNotNullOrEmpty())
            {
                return(Json(new { success = false, data = this.RenderPartialViewToString(Constants.PartialViews.AlertSliding, CaseGoalDetailTemplate) }));
            }
            else
            {
                return(Json(new { success = true, data = this.RenderPartialViewToString(Constants.PartialViews.AlertSliding, CaseGoalDetailTemplate) }));
            }
        }