public ProjectCategoryEditMode RenderEditProjectCategory(IdentityProjectCategory identity)
        {
            var editModel = new ProjectCategoryEditMode();

            editModel.Code   = identity.Code;
            editModel.Name   = identity.Name;
            editModel.Status = identity.Status;

            return(editModel);
        }
        public IdentityProjectCategory ExtractEditFromData(ProjectCategoryEditMode formData)
        {
            var myIdentity = new IdentityProjectCategory();

            myIdentity.Id     = formData.Id;
            myIdentity.Code   = formData.Code;
            myIdentity.Name   = formData.Name;
            myIdentity.Status = formData.Status;

            return(myIdentity);
        }
        public ActionResult Edit(ProjectCategoryEditMode model)
        {
            if (!ModelState.IsValid)
            {
                string messages = string.Join("; ", ModelState.Values
                                              .SelectMany(x => x.Errors)
                                              .Select(x => x.ErrorMessage + x.Exception));
                this.AddNotification(messages, NotificationType.ERROR);
                return(View(model));
            }


            try
            {
                var info = ExtractEditFromData(model);

                var isSuccess = _mainStore.Update(info);

                //Clear cache
                CachingHelpers.ClearProductCache(info.Id);

                if (isSuccess)
                {
                    this.AddNotification(ManagerResource.LB_UPDATE_SUCCESS, NotificationType.SUCCESS);
                }
            }
            catch (Exception ex)
            {
                this.AddNotification(NotifSettings.Error_SystemBusy, NotificationType.ERROR);

                logger.Error("Failed for Edit Product request: " + ex.ToString());

                return(View(model));
            }

            return(RedirectToAction("Edit/" + model.Id));
        }