コード例 #1
0
        public ActionResult Get(long id)
        {
            MethodBase method = MethodBase.GetCurrentMethod();

            try
            {
                if (id < 1)
                {
                    CreateLog(Enums.BadRequest, GetMethodCode(method), LogLevel.Information);
                    return(BadRequest());
                }
                var response = RoleRepo.Get(id);
                if (response != null)
                {
                    CreateLog(Enums.Success, GetMethodCode(method), LogLevel.Information);
                    return(Ok(response));
                }
                else
                {
                    CreateLog(Enums.NotFound, GetMethodCode(method), LogLevel.Warning);
                    return(NotFound());
                }
            }
            catch (Exception ex)
            {
                return(HandleError(ex.Message, GetMethodCode(method)));
            }
        }
コード例 #2
0
        public OperationResult Edit(EditRole command)
        {
            var operationresult = new OperationResult();

            var role = _roleRepo.Get(command.Id);

            if (role == null)
            {
                return(operationresult.Failed(ApplicationMessage.recordNotFound));
            }

            if (_roleRepo.Exists(c => c.Name == command.Name && c.Id != command.Id))
            {
                return(operationresult.Failed(ApplicationMessage.duplicated));
            }

            role.Edit(command.Name);
            _roleRepo.Save();
            return(operationresult.Succeeded());
        }