public async Task <ActionResult <CustomerResource_CustomerResourceDTO> > Update([FromBody] CustomerResource_CustomerResourceDTO CustomerResource_CustomerResourceDTO)
        {
            if (UnAuthorization)
            {
                return(Forbid());
            }
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            if (!await HasPermission(CustomerResource_CustomerResourceDTO.Id))
            {
                return(Forbid());
            }

            CustomerResource CustomerResource = ConvertDTOToEntity(CustomerResource_CustomerResourceDTO);

            CustomerResource = await CustomerResourceService.Update(CustomerResource);

            CustomerResource_CustomerResourceDTO = new CustomerResource_CustomerResourceDTO(CustomerResource);
            if (CustomerResource.IsValidated)
            {
                return(CustomerResource_CustomerResourceDTO);
            }
            else
            {
                return(BadRequest(CustomerResource_CustomerResourceDTO));
            }
        }
示例#2
0
        public async Task <IActionResult> UpdateCustomerResource(string id, [FromBody] CustomerResourceMeta customerResourceMeta)
        {
            var result = await _customerResourceService.Update(CurrentUser.TenantId, id, customerResourceMeta);

            if (result.Code <= 0)
            {
                return(BadRequest(result));
            }

            return(Ok(result));
        }