public ActionResult AddPickupDay() { var model = new AddPickupModel(); ViewBag.PickupDayId = new SelectList(db.PickupDay, "PickupDayId", "Name", model.PickupDayId); return(View(model)); }
public ActionResult AddPickupDay([Bind(Include = "PickupDayId")] AddPickupModel model) { var currentUserId = User.Identity.GetUserId(); Customer customer = db.Customer.Where(c => c.ApplicationUserID == currentUserId).Include(c => c.City).Include(c => c.State).Include(c => c.Zipcode).Include(c => c.PickupDay).FirstOrDefault(); Pickup pickup = new Pickup(); pickup.CustomerId = customer.CustomerId; pickup.PickupDayId = model.PickupDayId; pickup.PickupCost = 20.00; pickup.PickupStatus = false; pickup.ZipcodeId = customer.ZipcodeId; db.Pickup.Add(pickup); db.SaveChanges(); return(RedirectToAction("Index")); }