public ActionResult Create(Location location) { if (ModelState.IsValid) { location.CompanyId = CurrentUser.CompanyId; using (LocationsRepository locationsRepository = new LocationsRepository(CurrentUser.CompanyId)) { locationsRepository.Create(location); } return RedirectToAction("Index"); } ViewBag.CompanyId = new SelectList(db.Companies, "Id", "Name", location.CompanyId); return View(location); }
/// <summary> /// Deprecated Method for adding a new object to the Locations EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToLocations(Location location) { base.AddObject("Locations", location); }
/// <summary> /// Create a new Location object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="companyId">Initial value of the CompanyId property.</param> /// <param name="creationDate">Initial value of the CreationDate property.</param> /// <param name="city">Initial value of the City property.</param> /// <param name="address">Initial value of the Address property.</param> /// <param name="name">Initial value of the Name property.</param> public static Location CreateLocation(global::System.Int32 id, global::System.Int32 companyId, global::System.DateTime creationDate, global::System.String city, global::System.String address, global::System.String name) { Location location = new Location(); location.Id = id; location.CompanyId = companyId; location.CreationDate = creationDate; location.City = city; location.Address = address; location.Name = name; return location; }
public ActionResult Edit(Location location) { if (ModelState.IsValid) { location.CompanyId = CurrentUser.CompanyId; db.Locations.Attach(location); db.ObjectStateManager.ChangeObjectState(location, EntityState.Modified); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.CompanyId = new SelectList(db.Companies, "Id", "Name", location.CompanyId); return View(location); }