示例#1
0
        public ActionResult EditListing(int Id)
        {
            EasyServiceEntities easyServiceEntities = new EasyServiceEntities();
            VendorListing       vendorListing       = easyServiceEntities.VendorListings.Where(a => a.Id == Id).FirstOrDefault();

            return(View(vendorListing));
        }
示例#2
0
        public ActionResult EditListing(VendorListing model)
        {
            EasyServiceEntities easyServiceEntities = new EasyServiceEntities();

            easyServiceEntities.Entry(model).State = EntityState.Modified;
            easyServiceEntities.SaveChanges();
            return(RedirectToAction("ViewListing"));
        }
示例#3
0
        public ActionResult DeleteListing(int Id)
        {
            EasyServiceEntities easyServiceEntities = new EasyServiceEntities();
            VendorListing       vendorListing       = easyServiceEntities.VendorListings.Where(a => a.Id == Id).FirstOrDefault();

            easyServiceEntities.VendorListings.Remove(vendorListing);
            easyServiceEntities.SaveChanges();
            return(RedirectToAction("ViewListing"));
        }
示例#4
0
        public ActionResult AddListing(VendorListing model)
        {
            EasyServiceEntities easyServiceEntities = new EasyServiceEntities();

            var userId = easyServiceEntities.AspNetUsers.Where(a => a.UserName == User.Identity.Name).Select(x => x.Id).FirstOrDefault();

            model.UserId = userId;
            easyServiceEntities.VendorListings.Add(model);
            int c = easyServiceEntities.SaveChanges();

            return(RedirectToAction("ViewListing"));
        }
示例#5
0
        public IActionResult GetVendorListing([FromQuery] bool withMaterials)
        {
            var vendors = _vendorManager.GetVendors(withMaterials);

            var response = new List <VendorListing>();

            foreach (var vendor in vendors)
            {
                response.Add(VendorListing.MapFromObject(vendor));
            }

            return(Ok(response.OrderBy(vendor => vendor.Name).ToList()));
        }