Exemple #1
0
        public ActionResult Update([FromBody] CustomerDTO customerDTO)
        {
            if (!ModelState.IsValid)
            {
                return(NotFound());
            }

            applicationServiceCustomer.Update(customerDTO);

            return(Ok("Customer Changed successfully!"));
        }
Exemple #2
0
        public async Task <IActionResult> PutCustomer([FromRoute] Guid id, [FromBody] CustomerDto customer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != customer.Id)
            {
                return(BadRequest());
            }

            var customerUpdated = await _customerApplicationService.Update(customer, id);

            return(Ok(customerUpdated));
        }
        public ActionResult <CustomerDTO> Put(int id, [FromBody] CustomerDTO customerDTO)
        {
            try
            {
                CustomerDTO existingCustomer = _customerApplicationService.Get(id);

                if (existingCustomer is null)
                {
                    return(NotFound());
                }

                return(_customerApplicationService.Update(id, customerDTO));
            }
            catch (Exception ex)
            {
                return(BadRequest(new { ex.Message }));
            }
        }
Exemple #4
0
 public IActionResult Put(int id, [FromBody] CustomerInputUpdateDto customer)
 {
     _customerApplicationService.Update(id, customer);
     return(Ok("customer was updated sucessfully"));
 }