public ActionResult EditListing(int Id) { EasyServiceEntities easyServiceEntities = new EasyServiceEntities(); VendorListing vendorListing = easyServiceEntities.VendorListings.Where(a => a.Id == Id).FirstOrDefault(); return(View(vendorListing)); }
public ActionResult EditListing(VendorListing model) { EasyServiceEntities easyServiceEntities = new EasyServiceEntities(); easyServiceEntities.Entry(model).State = EntityState.Modified; easyServiceEntities.SaveChanges(); return(RedirectToAction("ViewListing")); }
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")); }
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")); }
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())); }