public async Task <IActionResult> PutVendorItemReview([FromRoute] long id, [FromBody] VendorItemReview vendorItemReview)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(NoContent());
        }
        public async Task <IActionResult> Edit(long id, [Bind("Id,comment,author,email,subject,rating,DateIn,Status")] VendorItemReview vendorItemReview)
        {
            if (id != vendorItemReview.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(vendorItemReview);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!VendorItemReviewExists(vendorItemReview.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(vendorItemReview));
        }
Esempio n. 3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,comment,author,email,subject,rating,DateIn,Status")] VendorItemReview vendorItemReviews, int itemId)
        {
            if (ModelState.IsValid)
            {
                var parms = new Dictionary <string, string>
                {
                    { "itemId", itemId.ToString() }
                };
                string userId = "";
                if (!string.IsNullOrEmpty(Request.Form["User"]))
                {
                    userId = Request.Form["User"];
                }
                else
                {
                    userId = _userManager.GetUserId(User);
                }
                var user = _context.Users.Find(userId);
                var item = _context.VendorItems.Find(itemId);
                _context.Update(vendorItemReviews);

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index), parms));
            }
            return(View(vendorItemReviews));
        }
        public async Task <IActionResult> Create([Bind("Id,comment,author,email,subject,rating,DateIn,Status")] VendorItemReview vendorItemReview)
        {
            if (ModelState.IsValid)
            {
                _context.Add(vendorItemReview);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(vendorItemReview));
        }
        public async Task <IActionResult> PostVendorItemReview([FromBody] VendorItemReview vendorItemReview)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.VendorItemReviews.Add(vendorItemReview);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetVendorItemReview", new { id = vendorItemReview.Id }, vendorItemReview));
        }