public async Task <IActionResult> PutOrders(int id, Orders orders)
        {
            if (id != orders.Oid)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        public async Task <IActionResult> PutMedicine(int id, Medicine medicine)
        {
            if (id != medicine.Mid)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Exemplo n.º 3
0
 public Medicine PutMedicine(int id, Medicine medicine)
 {
     _context.Entry(medicine).State = EntityState.Modified;
     _context.SaveChangesAsync();
     return(medicine);
 }
Exemplo n.º 4
0
 /* public void PostOrders(int id, int q, Orders o)
  * {
  *   using (var client = new HttpClient())
  *   {
  *       //Medicine m = new Medicine();
  *
  *       client.BaseAddress = new Uri("https://localhost:44335/");
  *       //client.BaseAddress = new Uri("http://52.224.82.33/");
  *       client.DefaultRequestHeaders.Accept.Clear();
  *       client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
  *       HttpResponseMessage response = new HttpResponseMessage();
  *       response = client.GetAsync("api/medicines").Result;
  *       var data = response.Content.ReadAsAsync<IEnumerable<Medicine>>().Result;
  *       Medicine medicine = (from p in data
  *                       where p.Mid == id
  *                       select p).FirstOrDefault();
  *       o.Mid = medicine.Mid;
  *
  *       o.Quantity = q;
  *       o.Totalcost = medicine.Price * o.Quantity;
  *       medicine.QuantityRemaining = medicine.QuantityRemaining - o.Quantity;
  *       _context.Orders.Add(o);
  *       //_context.Entry(medicine).State = EntityState.Modified;
  *       _context.SaveChangesAsync();
  *       //return o;
  *
  *       /*foreach(var y in data)
  *       {
  *           if(id == y.Mid)
  *           {
  *               o.Mid = id;
  *
  *               o.Totalcost = o.Quantity * y.Price;
  *           }
  *           m.QuantityRemaining = m.QuantityRemaining - o.Quantity;
  *       }
  *   }
  * }*/
 public Orders PutOrders(int id, Orders orders)
 {
     _context.Entry(orders).State = EntityState.Modified;
     _context.SaveChangesAsync();
     return(orders);
 }