public async Task <IActionResult> PutProduct(int id, Product product)
        {
            if (id != product.Id)
            {
                return(BadRequest());
            }

            _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> PutVendor(int id, Vendor vendor)
        {
            if (id != vendor.Id)
            {
                return(BadRequest());
            }

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

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

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

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

            try
            {
                await _context.SaveChangesAsync();

                RecalcuateRequestTotal(requestLine.RequestId);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RequestLineExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
示例#4
0
        public async Task <IActionResult> Create([Bind("Id,Code,Name,Address,City,State,Zip,Phone,Email")] Vendor vendor)
        {
            if (ModelState.IsValid)
            {
                _context.Add(vendor);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(vendor));
        }
示例#5
0
        public async Task <IActionResult> Create([Bind("Id,Username,Password,Firstname,Lastname,Phone,Email,IsReviewer,IsAdmin")] User user)
        {
            if (ModelState.IsValid)
            {
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(user));
        }
        public async Task <IActionResult> Create([Bind("Id,Description,Justification,RejectionReason,DeliveryMode,Status,Total,UserId")] Request request)
        {
            if (ModelState.IsValid)
            {
                _context.Add(request);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UserId"] = new SelectList(_context.Users, "Id", "Firstname", request.UserId);
            return(View(request));
        }
示例#7
0
        public async Task <IActionResult> Create([Bind("Id,PartNbr,Name,Price,Unit,Photopath,VendorId")] Product product)
        {
            if (ModelState.IsValid)
            {
                _context.Add(product);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["VendorId"] = new SelectList(_context.Vendors, "Id", "Address", product.VendorId);
            return(View(product));
        }
示例#8
0
        public async Task <IActionResult> Create([Bind("Id,RequestId,ProductId,Quantity")] RequestLine requestLine)
        {
            if (ModelState.IsValid)
            {
                _context.Add(requestLine);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProductId"] = new SelectList(_context.Products, "Id", "Name", requestLine.ProductId);
            ViewData["RequestId"] = new SelectList(_context.Requests, "Id", "DeliveryMode", requestLine.RequestId);
            return(View(requestLine));
        }