public ActionResult Create([Bind(Include = "Id,ZipCode,StreetName,StreetNum,Extra,CityId,CreatedTime,UpdatedTime")] Location location)
        {
            if (ModelState.IsValid)
            {
                db.Locations.Add(location);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CityId = new SelectList(db.Cities, "Id", "Name", location.CityId);
            return(View(location));
        }
        public ActionResult Create([Bind(Include = "Id,Name,About,Price,inStoke,Order,LocationId,CreatedTime,UpdatedTime")] CarsParts carsParts)
        {
            if (ModelState.IsValid)
            {
                db.CarsParts.Add(carsParts);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.LocationId = new SelectList(db.Locations, "Id", "ZipCode", carsParts.LocationId);
            return(View(carsParts));
        }
Example #3
0
 public void Create(T item)
 {
     Context.Set <T>().Add(item);
     Context.SaveChanges();
 }