示例#1
0
        public IHttpActionResult Post(RoleViewModel vm)
        {
            if (ModelState.IsValid)
            {
                bool isCompleted = false;
                try {
                    if (vm.IsDbRole)
                    {
                        isCompleted = _RoleService.AddDbUserRole(vm.RoleName, vm.EmpId, vm.Include);
                    }
                    else
                    {
                        isCompleted = _RoleService.AddUserRole(vm.RoleName, vm.User, vm.Include);
                    }
                } catch (SmartException ex) {
                    return(BadRequest(ex.Message));
                }


                if (!isCompleted)
                {
                    return(BadRequest("Save User Role was failed."));
                }

                RecordTransactionHistory(vm);
                return(Ok(isCompleted));
            }

            return(BadRequest(ModelState));
        }