示例#1
0
        public async Task <IActionResult> PutUser(int id, [FromForm] User User)
        {
            // if (User.ImgFile != null)
            // {
            //     DeleteImage(User.ImgName);
            //     User.ImgName = await SaveImage(User.ImgFile);
            // }

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

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

            return(NoContent());
        }
示例#2
0
        public async Task <IActionResult> PutOrder(int id)
        {
            var order_Deliv = await _context.Orders.FindAsync(id);

            order_Deliv.Deliverydate          = DateTime.Now;
            order_Deliv.Status                = "Delivered";
            _context.Entry(order_Deliv).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(NoContent());
        }
示例#3
0
        public async Task <IActionResult> PutFeedbackdatum(int id, Feedbackdatum feedbackdatum)
        {
            if (id != feedbackdatum.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
示例#4
0
        public async Task <IActionResult> PutProduct(int id, [FromForm] Product product)
        {
            if (product.ImgFile != null)
            {
                DeleteImage(product.ImgName);
                product.ImgName = await SaveImage(product.ImgFile);
            }

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

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

            return(NoContent());
        }
        public async Task <IActionResult> PutContact(int id, Contact contact)
        {
            if (id != contact.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
示例#6
0
        public async Task <ActionResult <Cartdetail> > PutCartdetail(int id, Cartdetail cartdetail)
        {
            cartdetail = await _context.Cartdetails.FindAsync(cartdetail.Id);

            if (id == -1)
            {
                if (cartdetail.Quanity > 1)
                {
                    cartdetail.Quanity = cartdetail.Quanity - 1;
                    _context.Entry(cartdetail).State = EntityState.Modified;
                }
            }
            else if (id == 1)
            {
                cartdetail.Quanity = cartdetail.Quanity + 1;
                _context.Entry(cartdetail).State = EntityState.Modified;
            }

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

            return(cartdetail);
        }
示例#7
0
        public async Task <IActionResult> PutCategory(int id, [FromForm] Category Category)
        {
            _context.Entry(Category).State = EntityState.Modified;

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

            return(NoContent());
        }