Exemple #1
0
        public ActionResult Create(RoleVM vm)
        {
            if (ModelState.IsValid)
            {
                var result = RoleSvc.Create(vm);
                return MyAjaxHelper.RedirectAjax(result, "");
            }

            var error = ModelState.Values.First(o => o.Errors.Count > 0).Errors[0].ErrorMessage;
            return MyAjaxHelper.RedirectAjax(AjaxStatusCode.Error, error, null, "");
        }
Exemple #2
0
        public ErrorCode Create(RoleVM vm)
        {
            try
            {
                if (RoleDal.GetExisted(o => o.Name == vm.Name))
                {
                    return ErrorCode.RoleNameExisted;
                }

                var role = new Role
                               {
                                   Name =  vm.Name,
                                   Description = vm.Description
                               };
                RoleDal.Create(role);

                return ErrorCode.NoError;
            }
            catch (Exception)
            {
                return ErrorCode.ServerError;
            }
        }