public void Add(reservation reservation) { int newId = db.reservations.ToList().Last().id + 1; reservation.id = newId; db.reservations.Add(reservation); db.SaveChanges(); }
public void Add(task task) { int newId = db.tasks.ToList().Last().id + 1; task.id = newId; db.tasks.Add(task); db.SaveChanges(); }
public void Add(user user) { int newId = db.users.ToList().Last().id + 1; user.id = newId; db.users.Add(user); db.SaveChanges(); }
public ActionResult Create([Bind(Include = "Id,Name,ApplyFrom,ApplyTo,BookingFrom,BookingTo,Remark")] Period period) { if (ModelState.IsValid) { db.Periods.Add(period); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(period)); }
public ActionResult Create([Bind(Include = "Id,Code,Name,Lead")] FSU fSU) { if (ModelState.IsValid) { db.FSUs.Add(fSU); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(fSU)); }
public ActionResult Create([Bind(Include = "Id,Name,Lead")] Line line) { if (ModelState.IsValid) { db.Lines.Add(line); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(line)); }
public ActionResult Create([Bind(Include = "Id,Name")] Level level) { if (ModelState.IsValid) { db.Levels.Add(level); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(level)); }
public ActionResult Create([Bind(Include = "Id,BuID,Code,Name,StartDate,EndDate,Manager,Note")] Project project) { if (ModelState.IsValid) { db.Projects.Add(project); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.BuID = new SelectList(db.BUs, "Id", "Code", project.BuID); return(View(project)); }
public ActionResult Create([Bind(Include = "Id,FsuID,Code,Name,Lead,Note")] BU bU) { if (ModelState.IsValid) { db.BUs.Add(bU); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.FsuID = new SelectList(db.FSUs, "Id", "Code", bU.FsuID); return(View(bU)); }
public bool DeleteBooking(string bookingId) { try { int bId = int.Parse(bookingId); BookingEntities ctx = new BookingEntities(); BoatBooking b = ctx.BoatBooking.Where(x => x.Id == bId).First(); BookingCancelledModel cm = new BookingCancelledModel { UserEmail = b.Member.Email, UserName = b.Member.Name, SailingClub = ConfigurationManager.AppSettings["SailingClub"], Signature = ConfigurationManager.AppSettings["Signature"], BookingReference = b.BookingMemberId.ToString() + "/" + b.Id.ToString(), BookingDate = b.BookingDate }; ctx.BoatBooking.Remove(b); ctx.SaveChanges(); UserMailer um = new UserMailer(); MvcMailMessage msg = um.BoatCancelledTreasurer(cm); msg.Send(); return(true); } catch (Exception) { return(false); } }
protected void AddRoom(object sender, EventArgs e) { try { var room = new Room { Category = insertCategory.Text, Type = insertType.Text, Price = Int32.Parse(insertPrice.Text), HId = Int32.Parse(sqlhotel.SelectedValue) }; db.Rooms.Add(room); db.SaveChanges(); ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect", "alert('Room inserted!'); window.location='" + Request.ApplicationPath + "Administrate.aspx';", true); } catch (Exception ex) { ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect", "alert('Room was not inserted:" + ex.Message + "'); window.location='" + Request.ApplicationPath + "Administrate.aspx';", true); } }
protected void AddReservation(object sender, EventArgs e) { try { var reservation = new Reservation { CId = Session["userid"].ToString(), RId = Int32.Parse(roomid.SelectedValue), StartDate = DateTime.Parse(insertStart.Text), EndDate = DateTime.Parse(insertEnd.Text) }; db.Reservations.Add(reservation); db.SaveChanges(); ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect", "alert('Reservation done!'); window.location='" + Request.ApplicationPath + "Reservations.aspx';", true); } catch (Exception ex) { ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect", "alert('Reservation has not been registered:" + ex.Message + "'); window.location='" + Request.ApplicationPath + "Reservations.aspx';", true); } }
public void Add(room room) { db.rooms.Add(room); db.SaveChanges(); }
public bool BookBoat(string bookingDate, string boatId) { BoatBooking b = null; BookingEntities ctx = null;; try { ctx = new BookingEntities(); int bId = int.Parse(boatId); Member booker = (Member)ctx.Member.Where(m => m.UserProfileId == WebSecurity.CurrentUserId).First(); Boat boat = (Boat)ctx.Boat.Find(bId); DateTime bd = DateTime.Parse(bookingDate); decimal cost = booker.Age < 18 ? 0.0m : boat.RentalCost; b = new BoatBooking { BookingDate = bd, BoatId = boat.Id, BookingMemberId = booker.Id, Units = 1, UnitCost = cost, TotalCost = cost }; ctx.BoatBooking.Add(b); ctx.SaveChanges(); b = ctx.BoatBooking.Where((bb) => bb.BookingMemberId == b.BookingMemberId && bb.BookingDate == b.BookingDate && bb.BoatId == b.BoatId).First(); BoatBookedModel mailModel = new BoatBookedModel { BoatName = boat.Make + " " + boat.Class + " " + boat.SailNumber, BookingDate = bd, Cost = cost, UserEmail = booker.Email, UserName = booker.Name, SailingClub = ConfigurationManager.AppSettings["SailingClub"], Signature = ConfigurationManager.AppSettings["Signature"], BookingReference = b.BookingMemberId.ToString() + "/" + b.Id.ToString() }; UserMailer um = new UserMailer(); MvcMailMessage msgUser = um.BoatBookedUser(mailModel); MvcMailMessage msgTreasurer = um.BoatBookedTreasurer(mailModel); msgUser.Send(); msgTreasurer.Send(); return(true); } catch { if (b != null && b.Id > 0) { if (ctx != null) { ctx.BoatBooking.Remove(b); ctx.SaveChanges(); } } return(false); } finally { if (ctx != null) { ctx.Dispose(); } } }