public ActionResult Bookings(Booking aBooking) { if (ModelState.IsValid) { Voucher aVoucher = new Voucher(); aVoucher.V_Discount = aBooking.Discount; db.Vouchers.Add(aVoucher); db.SaveChanges(); Payment aPayment = new Payment(); aPayment.Amount = aBooking.Amount; aPayment.Type = aBooking.Type; aPayment.Code = aBooking.Code; aPayment.VoucherId = aVoucher.Id; db.Payments.Add(aPayment); db.SaveChanges(); Buy_Sell abuySell = new Buy_Sell(); abuySell.FlatId = aBooking.Id; abuySell.UserId = Convert.ToInt32(Session["Id"].ToString()); abuySell.VoucherId = aVoucher.Id; abuySell.PaymentId = aPayment.Id; abuySell.All_Paper = false; abuySell.Description = ""; db.Buy_Sell.Add(abuySell); db.SaveChanges(); TempData["message"] = "Booing Successfully"; } return(View()); }
public ActionResult DeleteConfirmed(int id) { Buy_Sell buy_Sell = db.Buy_Sell.Find(id); db.Buy_Sell.Remove(buy_Sell); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,FlatId,UserId,VoucherId,All_Paper,Description,PaymentId")] Buy_Sell buy_Sell) { if (ModelState.IsValid) { db.Entry(buy_Sell).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.FlatId = new SelectList(db.Flats, "Id", "Name", buy_Sell.FlatId); ViewBag.PaymentId = new SelectList(db.Payments, "Id", "Type", buy_Sell.PaymentId); ViewBag.UserId = new SelectList(db.Users, "Id", "Name", buy_Sell.UserId); ViewBag.VoucherId = new SelectList(db.Vouchers, "Id", "Id", buy_Sell.VoucherId); return(View(buy_Sell)); }
// GET: BooKing/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Buy_Sell buy_Sell = db.Buy_Sell.Find(id); if (buy_Sell == null) { return(HttpNotFound()); } return(View(buy_Sell)); }
// GET: BooKing/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Buy_Sell buy_Sell = db.Buy_Sell.Find(id); if (buy_Sell == null) { return(HttpNotFound()); } ViewBag.FlatId = new SelectList(db.Flats, "Id", "Name", buy_Sell.FlatId); ViewBag.PaymentId = new SelectList(db.Payments, "Id", "Type", buy_Sell.PaymentId); ViewBag.UserId = new SelectList(db.Users, "Id", "Name", buy_Sell.UserId); ViewBag.VoucherId = new SelectList(db.Vouchers, "Id", "Id", buy_Sell.VoucherId); return(View(buy_Sell)); }