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

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

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

            return(NoContent());
        }
        public async Task <IActionResult> PutMedicine([FromRoute] int id, [FromBody] Medicine medicine)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

            var stopwatch = Stopwatch.StartNew();

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

            try
            {
                _logger.LogInformation($"Medicine with id# {id} is PUT. TimeElapsedInMilliSeconds: {stopwatch.ElapsedMilliseconds}");
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MedicineExists(id))
                {
                    _logger.LogError($"Medicine with id# {id} is not found. TimeElapsedInMilliSeconds: {stopwatch.ElapsedMilliseconds}");
                    return(NotFound());
                }

                throw;
            }

            return(NoContent());
        }
Esempio n. 3
0
        public async Task <IActionResult> PutMedicine([FromQuery] MedicineDTO medicineDTO)
        {
            var medicine = await _context.MedDbSet.FindAsync(medicineDTO.Id);

            if (medicine == null)
            {
                return(NoContent());
            }

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

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

            return(NoContent());
        }
 public ActionResult Edit([Bind(Include = "Id,Producer,Price,Name")] Medicine medicine)
 {
     if (ModelState.IsValid)
     {
         db.Entry(medicine).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(medicine));
 }
Esempio n. 5
0
 public ActionResult Edit([Bind(Include = "id,U_Name,U_Contact,U_Address,TotalBill,OrderDate,PaymentMethod")] Cart cart)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cart).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(cart));
 }
 public ActionResult Edit([Bind(Include = "id,A_Name,Email,A_UserName,A_Password,A_Cnic")] Admin admin)
 {
     if (ModelState.IsValid)
     {
         db.Entry(admin).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(admin));
 }
 public ActionResult Edit([Bind(Include = "Id,FirstName,LastName,Branch,Message,Email")] Contact contact)
 {
     if (ModelState.IsValid)
     {
         db.Entry(contact).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(contact));
 }
 public ActionResult Edit([Bind(Include = "id,M_Name,M_Company,M_Type,M_Potency,M_Details,M_Price")] Medicine medicine)
 {
     if (ModelState.IsValid)
     {
         db.Entry(medicine).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(medicine));
 }