public Parcel CreateParcel(Parcel order) { _context.Add(order); _context.SaveChanges(); return(order); }
public ActionResult Create([Bind(Include = "AdminId,Name,Email,Username,Password,ConfirmPassword,Phone,Address")] Admin admin) { if (ModelState.IsValid) { db.AdminTable.Add(admin); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(admin)); }
public ActionResult Create([Bind(Include = "ClientId,FirstName,LastName,Phone,PickupAddress,ItemDescription,ItemQuantity,FullName,ReceiverPhone,ReceiverAddress")] Client client) { if (ModelState.IsValid) { db.ClientTable.Add(client); db.SaveChanges(); ViewBag.Message = "Your delivery request has been successfully created"; ModelState.Clear(); return(View()); } return(View(client)); }
public ActionResult Create([Bind(Include = "PackageId,TrackingId,PackageStatus,ClientId")] Package package) { if (ModelState.IsValid) { package.TrackingId = Guid.NewGuid().ToString().Substring(0, 8); db.PackageTable.Add(package); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ClientId = new SelectList(db.ClientTable, "ClientId", "FirstName", package.ClientId); return(View(package)); }
public ActionResult Create([Bind(Include = "LastName,FirstMidName,HireDate,OfficeAssignment")] Drivers drivers, string[] selectedTrucks) { if (selectedTrucks != null) { drivers.Trucks = new List <Trucks>(); foreach (var course in selectedTrucks) { var trucksToAdd = db.Trucks.Find(int.Parse(course)); drivers.Trucks.Add(trucksToAdd); } } if (ModelState.IsValid) { db.Drivers.Add(drivers); db.SaveChanges(); return(RedirectToAction("Index")); } PopulateAssignedTrucksData(drivers); return(View(drivers)); }
public ActionResult Create([Bind(Include = "TruckID,Truck,Mileage,CustomerID")] Trucks trucks) { try { if (ModelState.IsValid) { db.Trucks.Add(trucks); db.SaveChanges(); return(RedirectToAction("Index")); } } catch (RetryLimitExceededException /* dex */) { //Log the error (uncomment dex variable name and add a line here to write a log.) ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator."); } PopulateCustomersDropDownList(trucks.CustomerID); return(View(trucks)); }
public bool Save(TDomain domain) { Context.Add(domain); return(Context.SaveChanges() > 0); }