示例#1
0
        public dynamic Update(UserAccess model, string colName, bool isAllow)
        {
            try
            {
                if (!AuthenticationModel.IsAllowed("Edit", Core.Constants.Constant.MenuName.UserAccessRight, Core.Constants.Constant.MenuGroupName.Setting))
                {
                    Dictionary <string, string> Errors = new Dictionary <string, string>();
                    Errors.Add("Generic", "You are Not Allowed to Edit record");

                    return(Json(new
                    {
                        Errors
                    }, JsonRequestBehavior.AllowGet));
                }

                var data = _userAccessService.GetObjectById(model.Id);
                switch (colName)
                {
                case "View": data.AllowView = isAllow; break;

                case "Create": data.AllowCreate = isAllow; break;

                case "Edit": data.AllowEdit = isAllow; break;

                case "Delete": data.AllowDelete = isAllow; break;

                case "UnDelete": data.AllowUndelete = isAllow; break;

                case "Confirm": data.AllowConfirm = isAllow; break;

                case "UnConfirm": data.AllowUnconfirm = isAllow; break;

                case "Paid": data.AllowPaid = isAllow; break;

                case "UnPaid": data.AllowUnpaid = isAllow; break;

                case "Reconcile": data.AllowReconcile = isAllow; break;

                case "UnReconcile": data.AllowUnreconcile = isAllow; break;

                case "ManualPricing": data.AllowSpecialPricing = isAllow; break;

                case "Print": data.AllowPrint = isAllow; break;
                }
                model = _userAccessService.UpdateObject(data, _userAccountService, _userMenuService);
            }
            catch (Exception ex)
            {
                LOG.Error("Update Failed", ex);
                Dictionary <string, string> Errors = new Dictionary <string, string>();
                Errors.Add("Generic", "Error " + ex);

                return(Json(new
                {
                    Errors
                }, JsonRequestBehavior.AllowGet));
            }

            return(Json(new
            {
                model.Errors
            }));
        }