Пример #1
0
        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));
        }
Пример #3
0
        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));
        }
Пример #4
0
        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));
        }
Пример #5
0
 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));
 }
Пример #6
0
        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);
 }