Esempio n. 1
0
        public async Task <IActionResult> PutService(int id, Service service)
        {
            if (id != service.Id)
            {
                return(BadRequest());
            }

            _context.Entry(service).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ServiceExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 2
0
        [Route("api/students/modifyStudent")] //zmień na student
        public IActionResult ModifyStudent(ModifyStudentRequest request)
        {
            var db = new _2019SBDContext();


            var s = new Student
            {
                IndexNumber = request.IndexNumber,
                FirstName   = request.FirstName,
                LastName    = request.LastName,
                BirthDate   = request.BirthDate
            };

            db.Attach(s);

            if (request.FirstName != null)
            {
                db.Entry(s).Property("FirstName").IsModified = true;
            }

            if (request.LastName != null)
            {
                db.Entry(s).Property("LastName").IsModified = true;
            }

            if (request.BirthDate != null)
            {
                db.Entry(s).Property("BirthDate").IsModified = true;
            }

            db.SaveChanges();
            var db2 = new _2019SBDContext();


            var res = db2.Student
                      .Where(d => d.IndexNumber == request.IndexNumber)
                      .FirstOrDefault();



            var response = new ModifyStudentResponse();

            response.IndexNumber = res.IndexNumber;
            response.FirstName   = res.FirstName;
            response.LastName    = res.LastName;
            response.BirthDate   = res.BirthDate;



            return(Ok(response));
        }
Esempio n. 3
0
        public IActionResult Update(int item_id, AchIngredient updated_item)
        {
            if (_context.AchIngredient.Count(e => e.IdIngredient == item_id) == 0)
            {
                return(NotFound());
            }

            _context.AchIngredient.Attach(updated_item);
            _context.Entry(updated_item).State = EntityState.Modified;
            _context.SaveChanges();
            return(Ok(updated_item));
        }
        public IActionResult Update(int id, AchCustomer updatedCustomer)
        {
            if (_context.AchCustomer.Count(e => e.IdCustomer == id) == 0)
            {
                return(NotFound());
            }

            _context.AchCustomer.Attach(updatedCustomer);
            _context.Entry(updatedCustomer).State = EntityState.Modified;
            _context.SaveChanges();
            return(Ok(updatedCustomer));
        }
        public IActionResult Update(int item_id, AchPizzaComposition updated_item)
        {
            if (_context.AchPizzaComposition.Count(e => e.PizzaCompositionId == item_id) == 0)
            {
                return(NotFound());
            }

            _context.AchPizzaComposition.Attach(updated_item);
            _context.Entry(updated_item).State = EntityState.Modified;
            _context.SaveChanges();
            return(Ok(updated_item));
        }
Esempio n. 6
0
        public IActionResult UpdateOrder(Zamowienie order)
        {
            if (_context.Zamowienie.Count(e => e.Id == order.Id) == 0)
            {
                return(NotFound());
            }

            _context.Zamowienie.Attach(order);
            _context.Entry(order).State = EntityState.Modified;
            _context.SaveChanges();

            return(Ok(order));
        }
Esempio n. 7
0
        public IActionResult UpdatePizza(Pizza pizza)
        {
            if (_context.Pizza.Count(e => e.Id == pizza.Id) == 0)
            {
                return(NotFound());
            }

            _context.Pizza.Attach(pizza);
            _context.Entry(pizza).State = EntityState.Modified;
            _context.SaveChanges();

            return(Ok(pizza));
        }
        public IActionResult Update(int item_id, AchOrder updated_item)
        {
            var item = _context.AchOrder.Count(e => e.IdOrder == item_id);

            if (item == 0)
            {
                return(NotFound());
            }

            _context.AchOrder.Attach(updated_item);
            _context.Entry(updated_item).State = EntityState.Modified;
            _context.SaveChanges();
            return(Ok(updated_item));
        }
        public IActionResult Update(int item_id, AchCustomerAlergen updated_item)
        {
            var item = _context.AchCustomerAlergen.Count(e => e.CustomerAlergenId == item_id);

            if (item == 0)
            {
                return(NotFound());
            }

            _context.AchCustomerAlergen.Attach(updated_item);
            _context.Entry(updated_item).State = EntityState.Modified;
            _context.SaveChanges();
            return(Ok(updated_item));
        }