Esempio n. 1
0
        [HttpPut("update/{id}")] //http:localhost:5000/statesOrder/update
        public async Task <IActionResult> UpdateStateOrder(long id, StateOrderModel stateOrder)
        {
            try
            {
                if (id != stateOrder.IdStateOrder)
                {
                    return(BadRequest());
                }
                else
                {
                    dBContext.Entry(stateOrder).State = EntityState.Modified; //
                    await dBContext.SaveChangesAsync();

                    return(NoContent());
                }
            }
            catch (Exception e)
            {
                bool existStateOrder = dBContext.StatesOrder.Any(e => e.IdStateOrder == id);
                if (!existStateOrder)
                {
                    return(NotFound());
                }
                else
                {
                    return(StatusCode(410));
                }
            }
        }
        public async Task <IActionResult> UpdateSpecialties_Vets(long id, Specialties_VetsModel specialties_vets)
        {
            try
            {
                if (id != specialties_vets.IdSpecialties_Vets)
                {
                    return(BadRequest());
                }
                else
                {
                    dBContext.Entry(specialties_vets).State = EntityState.Modified;
                    await dBContext.SaveChangesAsync();

                    return(NoContent());
                }
            }
            catch (Exception e)
            {
                bool existSpecialties_vets = dBContext.Specialties_Vets.Any(e => e.IdSpecialties_Vets == id);
                if (!existSpecialties_vets)
                {
                    return(NotFound());
                }
                else
                {
                    return(StatusCode(410));
                }
            }
        }
Esempio n. 3
0
        [HttpPut("update/{id}")] //http:localhost:5000/user/update
        public async Task <IActionResult> UpdateClient(long id, ClientModel client)
        {
            try
            {
                if (id != client.IdClient)
                {
                    return(BadRequest());
                }
                else
                {
                    dBContext.Entry(client).State = EntityState.Modified; //
                    await dBContext.SaveChangesAsync();

                    return(NoContent());
                }
            }
            catch (Exception e)
            {
                bool existClient = dBContext.Clients.Any(e => e.IdClient == id);
                if (!existClient)
                {
                    return(NotFound());
                }
                else
                {
                    return(StatusCode(410));
                }
            }
        }
Esempio n. 4
0
        [HttpPut("update/{id}")] //http:localhost:5000/order_products/update
        public async Task <IActionResult> UpdateOrder_Products(long id, Order_ProductsModel order_Products)
        {
            try
            {
                if (id != order_Products.IdOrder_Products)
                {
                    return(BadRequest());
                }
                else
                {
                    dBContext.Entry(order_Products).State = EntityState.Modified; //
                    await dBContext.SaveChangesAsync();

                    return(NoContent());
                }
            }
            catch (Exception e)
            {
                bool existOrder_Products = dBContext.Orders_Products.Any(e => e.IdOrder_Products == id);
                if (!existOrder_Products)
                {
                    return(NotFound());
                }
                else
                {
                    return(StatusCode(410));
                }
            }
        }
Esempio n. 5
0
        [HttpPut("update/{id}")]//http://localhost:5000/Category/update/2
        public async Task <IActionResult> UpdateCategory(CategoryModel category, long id)
        {
            try {
                if (id != category.IdCategory)
                {
                    return(BadRequest());
                }
                dBContext.Entry(category).State = EntityState.Modified;
                await dBContext.SaveChangesAsync();

                return(NoContent());
            }
            catch (Exception e) {
                bool categoryExist = dBContext.Categories.Any(e => e.IdCategory == id);
                if (!categoryExist)
                {
                    return(NotFound());
                }
                return(StatusCode(410));
            }
        }
Esempio n. 6
0
        public async Task <ActionResult> UpdateAppointment(AppointmentModel appointment, long id)
        {
            try{
                if (id != appointment.IdAppointment)
                {
                    return(BadRequest());
                }
                dBContext.Entry(appointment).State = EntityState.Modified;
                await dBContext.SaveChangesAsync();

                return(NoContent());
            }
            catch (Exception e) {
                bool appoitmentExist = dBContext.Appointments.Any(e => e.IdAppointment == id);
                if (!appoitmentExist)
                {
                    return(NotFound());
                }
                return(StatusCode(410));
            }
        }
        public async Task <IActionResult> UpdateVeterinarian(VeterinarianModel veterinarian, long id)
        {
            try {
                if (id != veterinarian.IdVeterinarian)
                {
                    return(BadRequest());
                }
                dBContext.Entry(veterinarian).State = EntityState.Modified;
                await dBContext.SaveChangesAsync();

                return(NoContent());
            }
            catch (Exception e) {
                bool veterinarianExist = dBContext.Veterinarians.Any(e => e.IdVeterinarian == id);
                if (!veterinarianExist)
                {
                    return(NotFound());
                }
                return(StatusCode(410));
            }
        }
        [HttpPut("update/{id}")]//http://localhost:5000/Product/update/2
        public async Task <IActionResult> UpdateProduct(ProductModel product, long id)
        {
            try {
                if (id != product.IdProduct)
                {
                    return(BadRequest());
                }
                dBContext.Entry(product).State = EntityState.Modified;
                await dBContext.SaveChangesAsync();

                return(NoContent());
            }
            catch (Exception e) {
                bool productExist = dBContext.Products.Any(e => e.IdProduct == id);
                if (!productExist)
                {
                    return(NotFound());
                }
                return(StatusCode(410));
            }
        }
Esempio n. 9
0
        public async Task <IActionResult> UpdateWishList(WishListModel wishList, long id)
        {
            try {
                if (id != wishList.IdWishList)
                {
                    return(BadRequest());
                }
                dBContext.Entry(wishList).State = EntityState.Modified;
                await dBContext.SaveChangesAsync();

                return(NoContent());
            }
            catch (Exception e) {
                bool wishListExist = dBContext.WishLists.Any(e => e.IdWishList == id);
                if (!wishListExist)
                {
                    return(NotFound());
                }
                return(StatusCode(410));
            }
        }
        public async Task <IActionResult> UpdateSpecialty(SpecialtyModel specialty, long id)
        {
            try {
                if (id != specialty.IdSpecialty)
                {
                    return(BadRequest());
                }
                dBContext.Entry(specialty).State = EntityState.Modified;
                await dBContext.SaveChangesAsync();

                return(NoContent());
            }
            catch (Exception e) {
                bool specialtyExist = dBContext.Specialties.Any(e => e.IdSpecialty == id);
                if (!specialtyExist)
                {
                    return(NotFound());
                }
                return(StatusCode(410));
            }
        }