// GET: WareHouses/Create public ActionResult Create() { var user = db.Users. Where(us => us.UserName == User.Identity.Name). FirstOrDefault(); ViewBag.CityId = new SelectList( ComboBoxHelpers. GetCities(), "CityId", "NameCity"); ViewBag.StateId = new SelectList( ComboBoxHelpers. GetStates(), "StateId", "NameState"); var warehouse = new WareHouse { CompanyId = user.CompanyId, }; return(View(warehouse)); }
// GET: WareHouses/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult( HttpStatusCode.BadRequest)); } var wareHouse = db.WareHouses.Find(id); if (wareHouse == null) { return(HttpNotFound()); } ViewBag.CityId = new SelectList( ComboBoxHelpers. GetCities(), "CityId", "NameCity", wareHouse.CityId); ViewBag.StateId = new SelectList( ComboBoxHelpers. GetStates(), "StateId", "NameState", wareHouse.StateId); return(View(wareHouse)); }
// GET: Users/Create public ActionResult Create() { ViewBag.CityId = new SelectList( ComboBoxHelpers. GetCities(0), "CityId", "NameCity"); ViewBag.CompanyId = new SelectList( ComboBoxHelpers. GetCompanies(), "CompanyId", "NameCompany"); ViewBag.StateId = new SelectList( ComboBoxHelpers. GetStates(), "StateId", "NameState"); return(View()); }
// GET: Cities/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult( HttpStatusCode.BadRequest)); } var city = db.Cities.Find(id); if (city == null) { return(HttpNotFound()); } ViewBag.StateId = new SelectList( ComboBoxHelpers. GetStates(), "StateId", "NameState", city.StateId); return(View(city)); }
public ActionResult Edit(WareHouse wareHouse) { if (ModelState.IsValid) { db.Entry(wareHouse).State = EntityState.Modified; try { db.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception ex) { if (ex.InnerException != null && ex.InnerException. InnerException != null && ex.InnerException. InnerException.Message. Contains("_Index")) { ModelState. AddModelError( string.Empty, "You Can't Add a New Record, Because There is Already One"); } else { ModelState. AddModelError( string.Empty, ex.Message); } } } ViewBag.CityId = new SelectList( ComboBoxHelpers. GetCities(), "CityId", "NameCity", wareHouse.CityId); ViewBag.StateId = new SelectList( ComboBoxHelpers. GetStates(), "StateId", "NameState", wareHouse.StateId); return(View(wareHouse)); }
// GET: Cities/Create public ActionResult Create() { ViewBag.StateId = new SelectList( ComboBoxHelpers. GetStates(), "StateId", "NameState"); return(View()); }
// GET: Users/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult( HttpStatusCode.BadRequest)); } var user = db.Users.Find(id); if (user == null) { return(HttpNotFound()); } ViewBag.CityId = new SelectList( ComboBoxHelpers. GetCities(user.StateId), "CityId", "NameCity", user.CityId); ViewBag.CompanyId = new SelectList( ComboBoxHelpers. GetCompanies(), "CompanyId", "NameCompany", user.CompanyId); ViewBag.StateId = new SelectList( ComboBoxHelpers. GetStates(), "StateId", "NameState", user.StateId); return(View(user)); }
// GET: Customers/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult( HttpStatusCode.BadRequest)); } var customer = db.Customers.Find(id); if (customer == null) { return(HttpNotFound()); } var user = db.Users. Where(us => us.UserName == User.Identity.Name). FirstOrDefault(); ViewBag.CityId = new SelectList( ComboBoxHelpers. GetCities(customer.StateId), "CityId", "NameCity", customer.CityId); ViewBag.StateId = new SelectList( ComboBoxHelpers. GetStates(), "StateId", "NameState", customer.StateId); return(View(customer)); }
public ActionResult Create(City city) { if (ModelState.IsValid) { db.Cities.Add(city); try { db.SaveChanges(); if (city.FlagFile != null) { var folder = "~/Content/Cities/FlagsCities"; var file = string.Format("{0}.jpg", city.CityId); var response = FilesHelpers. UploadPhoto( city.FlagFile, folder, file); if (response) { var pic = string.Format("{0}/{1}", folder, file); city.Flag = pic; db.Entry(city).State = EntityState.Modified; db.SaveChanges(); } } if (city.ShieldFile != null) { var folder1 = "~/Content/Cities/ShieldsCities"; var file1 = string.Format("{0}.jpg", city.CityId); var response1 = FilesHelpers. UploadPhoto( city.ShieldFile, folder1, file1); if (response1) { var pic = string.Format("{0}/{1}", folder1, file1); city.Shield = pic; db.Entry(city).State = EntityState.Modified; db.SaveChanges(); } } return(RedirectToAction("Index")); } catch (Exception ex) { if (ex.InnerException != null && ex.InnerException. InnerException != null && ex.InnerException. InnerException.Message. Contains("_Index")) { ModelState. AddModelError( string.Empty, "You Can't Add a New Record, Because There is Already One"); } else { ModelState. AddModelError( string.Empty, ex.Message); } } } ViewBag.StateId = new SelectList( ComboBoxHelpers. GetStates(), "StateId", "NameState", city.StateId); return(View(city)); }
public ActionResult Create(Company company) { if (ModelState.IsValid) { db.Companies.Add(company); var response = DBHelpers.SaveChanges(db); if (response.Succeeded) { if (company.LogoFile != null) { var folder = "~/Content/Logos"; var file = string.Format("{0}.jpg", company.CompanyId); var response0 = FilesHelpers. UploadPhoto( company.LogoFile, folder, file); if (response0) { var pic = string.Format("{0}/{1}", folder, file); company.Logo = pic; db.Entry(company).State = EntityState.Modified; db.SaveChanges(); } } return(RedirectToAction("Index")); } ModelState.AddModelError( string.Empty, response.Message); } ViewBag.CityId = new SelectList( ComboBoxHelpers. GetCities(company.StateId), "CityId", "NameCity", company.CityId); ViewBag.StateId = new SelectList( ComboBoxHelpers. GetStates(), "StateId", "NameState", company.StateId); return(View(company)); }
public ActionResult Create(User user) { if (ModelState.IsValid) { db.Users.Add(user); var response = DBHelpers.SaveChanges(db); if (response.Succeeded) { UsersHelpers. CreateUserASP(user.UserName, "User"); if (user.PhotoFile != null) { var folder = "~/Content/Photos"; var file = string.Format("{0}.jpg", user.UserID); var response0 = FilesHelpers. UploadPhoto( user.PhotoFile, folder, file); if (response0) { var pic = string.Format("{0}/{1}", folder, file); user.Photo = pic; db.Entry(user).State = EntityState.Modified; db.SaveChanges(); } } return(RedirectToAction("Index")); } ModelState.AddModelError( string.Empty, response.Message); } ViewBag.CityId = new SelectList( ComboBoxHelpers. GetCities(user.StateId), "CityId", "NameCity", user.CityId); ViewBag.CompanyId = new SelectList( ComboBoxHelpers. GetCompanies(), "CompanyId", "NameCompany", user.CompanyId); ViewBag.StateId = new SelectList( ComboBoxHelpers. GetStates(), "StateId", "NameState", user.StateId); return(View(user)); }
public ActionResult Create(Customer customer) { var user = db.Users. Where(us => us.UserName == User.Identity.Name). FirstOrDefault(); if (ModelState.IsValid) { db.Customers.Add(customer); var response = DBHelpers.SaveChanges(db); if (response.Succeeded) { if (customer.LogoCFile != null) { var folder = "~/Content/Customers"; var file = string.Format("{0}.jpg", customer.CustomerID); var response0 = FilesHelpers. UploadPhoto( customer.LogoCFile, folder, file); if (response0) { var pic = string.Format("{0}/{1}", folder, file); customer.LogoC = pic; db.Entry(customer).State = EntityState.Modified; db.SaveChanges(); } } return(RedirectToAction("Index")); } ModelState.AddModelError( string.Empty, response.Message); } ViewBag.CityId = new SelectList( ComboBoxHelpers. GetCities(customer.StateId), "CityId", "NameCity", customer.CityId); ViewBag.StateId = new SelectList( ComboBoxHelpers. GetStates(), "StateId", "NameState", customer.StateId); return(View(customer)); }