public ActionResult Create(SpecialPriceViewModel specialPriceModel) { if (ModelState.IsValid) { SpecialPrice sp = new SpecialPrice(); sp.Id = specialPriceModel.Id; sp.Price = specialPriceModel.Price; sp.StartDate = specialPriceModel.StartDate; sp.EndDate = specialPriceModel.EndDate; db.Rooms.Find(specialPriceModel.RoomId).specialPrices.Add(sp); db.SaveChanges(); return RedirectToAction("Detail/" + specialPriceModel.RoomId, "Room"); } return View(specialPriceModel); }
public ActionResult Create(int id) { SpecialPriceViewModel sp = new SpecialPriceViewModel(); sp.RoomId = id; return View(sp); }