Пример #1
0
        public void Create(int Shipmentid, int Nomenclid, decimal Price, decimal Quantity)
        {
            if (ModelState.IsValid)
            {
                Shipdoc shipdoc = new Shipdoc()
                {
                    Shipmentid = Shipmentid, Nomenclid = Nomenclid, Price = Price, Quantity = Quantity
                };
                try
                {
                    //Проверяем на наличие такой-же записи.
                    if (_context.Shipdoc.Any(b => b.Shipmentid == shipdoc.Shipmentid && b.Nomenclid == shipdoc.Nomenclid))
                    {
                        _context.Shipdoc.Where(b => b.Shipmentid == shipdoc.Shipmentid && b.Nomenclid == shipdoc.Nomenclid).Update(b => new Shipdoc()
                        {
                            Price = shipdoc.Price, Quantity = shipdoc.Quantity
                        });
                    }
                    else
                    {
                        _context.Add(shipdoc);
                        _context.SaveChanges();
                    }

                    return;
                }
                catch
                {
                    return;
                }
            }
            return;
        }
Пример #2
0
        public async Task <IActionResult> Create([Bind("Id,Name,Deleted")] Groupnom groupnom)
        {
            if (ModelState.IsValid)
            {
                _context.Add(groupnom);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(groupnom));
        }
Пример #3
0
        public async Task <IActionResult> Create([Bind("Id,Name,Groupnomid,Deleted")] Nomencl nomencl)
        {
            if (ModelState.IsValid)
            {
                _context.Add(nomencl);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Groupnomid"] = new SelectList(_context.Groupnom.Where(b => !b.Deleted), "Id", "Name", nomencl.Groupnomid);
            return(View(nomencl));
        }
Пример #4
0
        public async Task <IActionResult> Create([Bind("Supplyerid")] Shipment shipment)
        {
            if (ModelState.IsValid)
            {
                shipment.Suppdate = UnixTimeConverter.ConvertToUnixTimestamp(DateTime.Now.Date);
                shipment.Deleted  = false;
                _context.Add(shipment);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Create", "Shipdocs", new { shipmentid = shipment.Id }));
            }
            ViewData["Supplyerid"] = new SelectList(_context.Supplyer.Where(b => !b.Deleted), "Id", "Name", shipment.Supplyerid);
            return(View(shipment));
        }
Пример #5
0
 public async Task <IActionResult> Create([Bind("Supplyerid,Nomenclid,Price")] Prices prices)
 {
     if (ModelState.IsValid)
     {
         prices.Price = Math.Round(prices.Price, 2);
         try
         {
             //Проверяем на наличие такой-же записи.
             if (_context.Prices.Any(b => b.Supplyerid == prices.Supplyerid && b.Nomenclid == prices.Nomenclid))
             {
                 _context.Prices.Where(b => b.Supplyerid == prices.Supplyerid && b.Nomenclid == prices.Nomenclid).Update(b => new Prices()
                 {
                     Price = prices.Price
                 });
             }
             else
             {
                 _context.Add(prices);
                 await _context.SaveChangesAsync();
             }
         }
         catch (DbUpdateConcurrencyException)
         {
             if (!PricesExists(prices.Id))
             {
                 return(NotFound());
             }
             else
             {
                 throw;
             }
         }
         return(RedirectToAction(nameof(Index)));
     }
     ViewData["Nomenclid"]  = new SelectList(_context.Nomencl.Where(b => !b.Deleted), "Id", "Name", prices.Nomenclid);
     ViewData["Supplyerid"] = new SelectList(_context.Supplyer.Where(b => !b.Deleted), "Id", "Name", prices.Supplyerid);
     ViewData["Groupid"]    = new SelectList(_context.Groupnom.Where(b => !b.Deleted), "Id", "Name", GetGroupId(prices.Nomenclid));
     return(View(prices));
 }