Exemple #1
0
        public async Task <IActionResult> Add(StockReceipt model)
        {
            var user = await GetCurrentUserAsync();

            var siteId = user.SiteID;

            if (ModelState.IsValid)
            {
                model.SiteId       = siteId;
                model.ReceivedBy   = user.Name;
                model.DateReceived = DateTime.Now;

                _repository.AddStockReceipt(model);
                CreateStockRecord(model);
                ModelState.Clear();

                return(RedirectToAction("list", new { id = "success" }));
            }

            //Loads the dropdown data
            ViewBag.ProductId  = new SelectList(_repository.GetAllProducts(siteId), "ProductId", "ProductCode");
            ViewBag.LocationId = new SelectList(_repository.GetAllLocations(siteId), "LocationId", "Name");

            return(View(model));
        }