Beispiel #1
0
        [ProducesResponseType(StatusCodes.Status500InternalServerError)] // if something unexpectedly went wrong with the database or http request/response
        public async Task <IActionResult> PutCustomer(int id, Furs2Feathers.Domain.Models.Customer customer)
        {
            if (id != customer.CustomerId)
            {
                return(BadRequest());
            }

            /*_context.Entry(customer).State = EntityState.Modified;*/
            if (!await customerRepo.ModifyStateAsync(customer, id))
            {
                return(NotFound());
                // if false, then modifying state failed
            }
            else
            {
                return(NoContent());
                // successful put
            }
        }
Beispiel #2
0
        [ProducesResponseType(StatusCodes.Status500InternalServerError)]                                   // if something unexpectedly went wrong with the database or http request/response
        public async Task <ActionResult <Furs2Feathers.Domain.Models.Customer> > PostCustomer(Furs2Feathers.Domain.Models.Customer customer)
        {
            customerRepo.Add(customer);
            await customerRepo.SaveChangesAsync();

            int highest_id = customerRepo.HighestID();

            customer.CustomerId = highest_id;

            return(CreatedAtAction("GetCustomer", new { id = customer.CustomerId }, customer));
        }