Ejemplo n.º 1
0
        public async Task <IActionResult> Edit()
        {
            if (RouteData.Values.ContainsKey("Id"))
            {
                var user = await GetCurrentUserAsync();

                var siteId = user.SiteID;

                string key;
                key = RouteData.Values["Id"].ToString();

                Product model = new Product();
                model = _repository.GetProduct(key, siteId);

                //Loads the dropdown data
                ViewBag.CategoryId = new SelectList(_repository.GetAllCategories(siteId), "CategoryId", "Name", model.CategoryId);
                ViewBag.UOMId      = new SelectList(_repository.GetAllUOMs(siteId), "UOMId", "Name", model.UOMId);
                ViewBag.LocationId = new SelectList(_repository.GetAllLocations(siteId), "LocationId", "Name", model.LocationId);

                return(View(model));
            }
            else
            {
                return(RedirectToAction("list"));
            }
        }