示例#1
0
        //Updates the product retailer mapping record.
        public IActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Attach(ProductRetailerRegistration).State = EntityState.Modified;

            try
            {
                _context.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProductRetailerRegistrationExists(ProductRetailerRegistration.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
        //Adds a retailer to databse.
        public IActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Retailer.Add(Retailer);
            _context.SaveChanges();

            return(RedirectToPage("./Index"));
        }
示例#3
0
        //Adds a product registration mapping to databse.
        public IActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.ProductRetailerRegistration.Add(ProductRetailerRegistration);
            _context.SaveChanges();

            return(RedirectToPage("./Index"));
        }
示例#4
0
        //Adds the new category.
        public IActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.ProductCategory.Add(ProductCategory);
            _context.SaveChanges();

            return(RedirectToPage("./Index"));
        }
        //Removes the retailer product registraion. Uses a linq query to check availability.
        public IActionResult OnPost(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            ProductRetailerRegistration = (from retailerProd in _context.ProductRetailerRegistration
                                           where retailerProd.Id == id
                                           select retailerProd).FirstOrDefault();

            if (ProductRetailerRegistration != null)
            {
                _context.ProductRetailerRegistration.Remove(ProductRetailerRegistration);
                _context.SaveChanges();
            }

            return(RedirectToPage("./Index"));
        }
示例#6
0
        //Deletes the category uses a linq query to get the category.
        public IActionResult OnPost(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            ProductCategory = (from category in _context.ProductCategory

                               where category.Id == id
                               select category).FirstOrDefault();

            if (ProductCategory != null)
            {
                _context.ProductCategory.Remove(ProductCategory);
                _context.SaveChanges();
            }

            return(RedirectToPage("./Index"));
        }
示例#7
0
        //Removes the record uses a linq query to get the record.
        public IActionResult OnPost(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Product = (from product in _context.Product

                       where product.Id == id
                       select product).FirstOrDefault();

            if (Product != null)
            {
                _context.Product.Remove(Product);
                _context.SaveChanges();
            }

            return(RedirectToPage("./Index"));
        }
示例#8
0
        //Removes a retailer. uses a linq query to get the record
        public IActionResult OnPost(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Retailer = (from retailer in _context.Retailer

                        where retailer.Id == id
                        select retailer).FirstOrDefault();

            if (Retailer != null)
            {
                _context.Retailer.Remove(Retailer);
                _context.SaveChanges();
            }

            return(RedirectToPage("./Index"));
        }