示例#1
0
        public void Add(reservation reservation)
        {
            int newId = db.reservations.ToList().Last().id + 1;

            reservation.id = newId;
            db.reservations.Add(reservation);
            db.SaveChanges();
        }
示例#2
0
        public void Add(task task)
        {
            int newId = db.tasks.ToList().Last().id + 1;

            task.id = newId;
            db.tasks.Add(task);
            db.SaveChanges();
        }
示例#3
0
        public void Add(user user)
        {
            int newId = db.users.ToList().Last().id + 1;

            user.id = newId;
            db.users.Add(user);
            db.SaveChanges();
        }
示例#4
0
        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));
        }
示例#5
0
        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));
        }
示例#6
0
        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));
        }
示例#7
0
        public ActionResult Create([Bind(Include = "Id,Name")] Level level)
        {
            if (ModelState.IsValid)
            {
                db.Levels.Add(level);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(level));
        }
示例#8
0
        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));
        }
示例#9
0
        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));
        }
示例#10
0
 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);
     }
 }
示例#13
0
 public void Add(room room)
 {
     db.rooms.Add(room);
     db.SaveChanges();
 }
示例#14
0
        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();
                }
            }
        }