public bool UpdateBooking(booking bookingObj)
        {
            Models.apartma2Entities entities = new Models.apartma2Entities();
            try
            {
                Models.booking bookingModel = entities.bookings.FirstOrDefault(el => el.id.Equals(bookingObj.id));
                if (bookingModel != null)
                {
                    bookingModel.id        = bookingObj.id;
                    bookingModel.date_from = bookingObj.date_from;
                    bookingModel.date_to   = bookingObj.date_to;
                    bookingModel.status    = bookingObj.status.ToString();
                    bookingModel.apartment = ApartmentTypeConverter.ApartmentObjToModel(bookingObj.apartment);
                    //bookingModel.customer = ApartmentTypeConverter.CustomerObjToModel(bookingObj.customer);
                    bookingModel.payment_method = ApartmentTypeConverter.PaymentObjToModel(bookingObj.payment);
                    bookingModel.discount       = ApartmentTypeConverter.DiscountObjToModel(bookingObj.discount);

                    entities.Entry(bookingModel).State = System.Data.Entity.EntityState.Modified;
                    entities.SaveChanges();
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Beispiel #2
0
        public IHttpActionResult Putbooking(int id, booking booking)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != booking.id)
            {
                return(BadRequest());
            }

            db.Entry(booking).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!bookingExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public bool processCancelBooking(booking bookObj)
        {
            sports = new SportsAllEntities();
            book   = new booking();
            svf    = new slotvsFacility();
            var bookingRec = from y in sports.bookings
                             where y.BookingId == bookObj.BookingId
                             select y;

            book = bookingRec.First <booking>();
            var slotFacId = from z in sports.slotvsFacilities
                            where z.FacilityId == book.FacilityId && z.SlotId == book.SlotID
                            select z;

            svf            = slotFacId.First <slotvsFacility>();
            svf.Available  = "Y";
            book.confirmed = "N";
            using (TransactionScope ts = new TransactionScope())
            {
                sports.SaveChanges();
                sports.SaveChanges();
                ts.Complete();
                return(true);
            }
            //return false;
        }
 public booking GetBooking(int id, int userId, int apartmentId, int dateFrom, int dateTo)
 {
     Models.apartma2Entities entities = new Models.apartma2Entities();
     try
     {
         Models.booking bookingModel = entities.bookings.FirstOrDefault(el => el.id.Equals(id) || el.customer_trr.Equals(userId) || el.apartment.id.Equals(apartmentId) ||
                                                                        (el.date_from >= dateFrom && el.date_to <= dateTo));
         if (bookingModel != null)
         {
             booking bookingObj = new booking
             {
                 id        = bookingModel.id,
                 date_from = bookingModel.date_from,
                 date_to   = bookingModel.date_to,
                 //customer = ApartmentTypeConverter.CustomerModelToObj(bookingModel.customer),
                 apartment = ApartmentTypeConverter.ApartmentModelToObj(bookingModel.apartment),
                 status    = ApartmentTypeConverter.BookingStatusStringToEnum(bookingModel.status),
                 discount  = ApartmentTypeConverter.DiscountModelToObj(bookingModel.discount),
                 payment   = ApartmentTypeConverter.PaymentModelToObj(bookingModel.payment_method)
             };
             return(bookingObj);
         }
         else
         {
             return(null);
         }
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
 public ActionResult Edit([Bind(Include = "booking_id, customer_id, room_id, date_in,File,status")] booking bookings, Room rooms)
 {
     try
     {
         // TODO: Add update logic here
         if (bookings.status == "verified")
         {
             rooms.status = "Not Available";
         }
         else if (bookings.status == "not verified")
         {
             rooms.status = "Available";
         }
         db.Entry(bookings).State = EntityState.Modified;
         db.Entry(rooms).State    = EntityState.Modified;
         db.Entry(rooms).Property(x => x.type_id).IsModified   = false; //keep data not modified
         db.Entry(rooms).Property(x => x.Room_info).IsModified = false;
         db.Entry(rooms).Property(x => x.url).IsModified       = false;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View(db.booking));
     }
 }
Beispiel #6
0
        public void AddUpdateBooking(BookingEntity bookingRequest)
        {
            bookingRequest.BookingId = Guid.NewGuid().ToString();
            var bookingEntity = new booking()
            {
                BookedBy       = bookingRequest.BookedBy,
                bookedtables   = new List <bookedtable>(),
                BookingDate    = bookingRequest.BookingDate,
                BookingId      = bookingRequest.BookingId.ToString(),
                Email          = bookingRequest.Email,
                EndTime        = bookingRequest.EndTime,
                FirstName      = bookingRequest.FirstName,
                LastName       = bookingRequest.LastName,
                Notes          = bookingRequest.Notes,
                NumberOfGuests = bookingRequest.NumberOfGuests,
                PhoneNumber    = bookingRequest.PhoneNumber,
                StartTime      = bookingRequest.StartTime,
                HasArrived     = bookingRequest.hasArrived,
                CustomerId     = _customerId
            };
            var customerTableList = _dataAccess.GetTableList();

            foreach (var table in bookingRequest.TableNumbers)
            {
                var selectedTable = customerTableList.FirstOrDefault(t => t.TableNumber == table.TableNumber);
                bookingEntity.bookedtables.Add(new bookedtable()
                {
                    BookingId = bookingRequest.BookingId.ToString(),
                    TableId   = selectedTable.TableId
                });
            }

            _dataAccess.AddUpdateBooking(bookingEntity);
        }
Beispiel #7
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                bfc    = new BookingFacilityControl();
                sports = new SportsAllEntities();
                book   = new booking();
                svf    = new slotvsFacility();

                book.BookingId   = Convert.ToInt32(txtbookingId.Text);
                book.MemberId    = Convert.ToInt32(txtMemId.Text);
                book.FacilityId  = GetSelectedFacility;
                book.SlotID      = Convert.ToInt32(HiddenSlotIdLabel.Text);
                book.DateOfUse   = dateOfUseddtp.Value.ToShortDateString();
                book.WeekdayName = dateOfUseddtp.Value.DayOfWeek.ToString();
                book.confirmed   = "Y";
                bfc.saveBooking(book);
                DialogResult r = MessageBox.Show("Do you want a Booking Receipt", "Booking Receipt", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                if (r == System.Windows.Forms.DialogResult.Yes)
                {
                    bfc.showBookingReceipt(book.BookingId);
                }
                displayControlValues();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #8
0
        public ActionResult Create([Bind(Include = "booking_id,customer_id,room_id,date_in,File,status,Email")] booking booking)
        {
            var file = Request.Files[0];

            if (file != null && file.ContentLength > 0)
            {
                var fileName = Path.GetFileName(file.FileName);
                var path     = Path.Combine(Server.MapPath(" ~/Content/contract/"), fileName);
                file.SaveAs(path);
                booking.File = fileName;
            }


            try
            {
                // TODO: Add insert logic here
                ViewBag.roomlist    = new SelectList(db.booking, "room_id");
                booking.status      = "not verified";
                booking.customer_id = User.Identity.GetUserId();
                booking.Email       = User.Identity.GetUserName();
                db.booking.Add(booking);
                db.SaveChanges();
                return(View("Success"));
            }
            catch
            {
                return(View(booking));
            }
        }
Beispiel #9
0
 private void btnCancel_Click(object sender, EventArgs e)
 {
     try
     {
         DialogResult r = MessageBox.Show("Are you sure you want to cancel the booking", "CancelBooking", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (r == System.Windows.Forms.DialogResult.Yes)
         {
             cc                       = new CancelControl();
             bookingDetails           = new booking();
             bookingDetails.BookingId = Convert.ToInt32(BookingIdComboBox.Text);
             bool UpdateResult = cc.processCancelBooking(bookingDetails);
             if (UpdateResult)
             {
                 MessageBox.Show("Booking cancelled");
             }
             else
             {
                 MessageBox.Show("Ensure all the entries are correct");
             }
             display();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Please enter all the details to cancel");
     }
 }
        public GetBookingResponse GetBooking(GetBookingRequest request)
        {
            AdministrationServiceDAO adminDAO = new AdministrationServiceDAO();
            booking result = adminDAO.GetBooking(request.id, request.user_id, request.apartment_id, request.date_from, request.date_to);

            return(new GetBookingResponse(result));
        }
Beispiel #11
0
        public RentRoomViewModel()
        {
            roomRepository          = new BaseRepository <room>();
            bookingRepository       = new BaseRepository <booking>();
            bookingDetailRepository = new BaseRepository <booking_details>();
            serviceDetailRepository = new BaseRepository <service_details>();
            servicelRepository      = new BaseRepository <service>();

            int roomID = (int)System.Windows.Application.Current.Properties["CurrentRoomID"];

            //Messenger.Default.Register<Parameter>(this, res => Room = GetRoom(((int)res.param)));
            Room             = GetRoom(roomID);
            ListService      = getFullService();
            BookingInfo      = new booking();
            ListServiceAdded = new BindingList <service_details>();

            NumOfPeole = 1;

            RoomCost    = 0;
            ServiceCost = 0;
            Discount    = 0;
            TotalCost   = 0;

            //StartDate = new DateTime(DateTime.Now.Ticks);
            //StartTime = new DateTime(DateTime.Now.Ticks);
            //EndDate = new DateTime(DateTime.Now.Ticks);
            //EndTime = new DateTime(DateTime.Now.Ticks);

            StartDate = DateTime.Now;
            StartTime = DateTime.Now;
            EndDate   = DateTime.Now;
            EndTime   = DateTime.Now;
        }
Beispiel #12
0
        public JsonResult saveEvent(booking e)
        {
            var status = false;

            using (portableDBEntities dbmodel = new portableDBEntities())
            {
                if (e.bkid > 0)
                {
                    var v = dbmodel.bookings.Where(a => a.bkid == e.bkid).FirstOrDefault();
                    if (v != null)
                    {
                        v.bkdate1 = e.bkdate1;
                        v.bkdate2 = e.bkdate2;
                    }
                }
                else
                {
                    dbmodel.bookings.Add(e);
                }
                dbmodel.SaveChanges();
                status = true;
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
 public bool BookRoom(int roomId, DateTime date)
 {
     using (HotelmanagementEntities db = new HotelmanagementEntities())
     {
         bool status = false;
         try
         {
             booking temp = db.bookings.Where(x => x.roomid == roomId && x.bookingdate == date).FirstOrDefault();
             if (temp != null)
             {
                 return(status);
             }
             booking booking = new booking {
                 roomid = roomId, bookingdate = date, bookingstatus = "optional"
             };
             db.bookings.Add(booking);
             if (db.SaveChanges() > 0)
             {
                 status = true;
             }
             return(status);
         }
         catch (Exception e)
         {
             Console.WriteLine(e.Message);
             return(false);
         }
     }
 }
        public ActionResult DeleteConfirmed(int id)
        {
            booking bookings = db.booking.Find(id);

            db.booking.Remove(bookings);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #15
0
 private void frmBookingFacility_Load(object sender, EventArgs e)
 {
     sports = new SportsAllEntities();
     book   = new booking();
     fac    = new facility();
     svf    = new slotvsFacility();
     dateOfUseddtp.Value = DateTime.Now.AddDays(1);
 }
Beispiel #16
0
        public ActionResult showtrips()
        {
            booking pt = new booking();

            pt.trips = db.trips.ToList();

            return(View(pt));
        }
        public ActionResult DeleteConfirmed(Guid id)
        {
            booking booking = db.bookings.Find(id);

            db.bookings.Remove(booking);
            db.SaveChanges();
            return(RedirectToAction("Index", new { id = resid }));
        }
Beispiel #18
0
        public ActionResult booking(booking model)
        {
            var data = new resultJSON();

            if (model != null)
            {
                // checkemail
                //if (db.bookings.Any(x=>x.email == model.email))
                //{
                //    data.success = "0";
                //    data.msb.Add(new MsbList() { field = "booking_email", error = "Email đã được sử dụng." });

                //}
                // check phone
                //if (db.bookings.Any(x => x.phone == model.phone))
                //{
                //    data.success = "0";
                //    data.msb.Add(new MsbList() { field = "booking_phone", error = "Số điện thoại đã được sử dụng." });
                //}

                //if (data.success == "0")
                //{
                //    return Json(data, JsonRequestBehavior.AllowGet);
                //}

                // add data
                booking newbooking = new booking();
                newbooking.full_name = model.full_name ?? null;
                newbooking.phone     = model.phone ?? null;
                newbooking.email     = model.email ?? null;
                MD5    md5Hash  = MD5.Create();
                string passHash = Configs.GetMd5Hash(md5Hash, model.pass);
                newbooking.pass          = passHash;
                newbooking.time_go       = model.time_go ?? null;
                newbooking.time_to       = model.time_to ?? null;
                newbooking.from_location = model.from_location ?? null;
                newbooking.to_location   = model.to_location ?? null;
                newbooking.long_from     = model.long_from ?? null;
                newbooking.lat_from      = model.lat_from ?? null;
                newbooking.long_to       = model.long_to ?? null;
                newbooking.lat_to        = model.lat_to ?? null;
                newbooking.km1           = model.km1 ?? null;
                newbooking.type          = model.type ?? null;
                newbooking.type_vehicle  = model.type_vehicle ?? null;
                newbooking.status        = 0;
                newbooking.date_time     = DateTime.Now;
                newbooking.sex           = model.sex ?? null;
                newbooking.group_by      = model.group_by ?? null;
                //newbooking.group_number = model.group_number ?? null;
                db.bookings.Add(newbooking);
                db.SaveChanges();
                data.success = "1";
                data.msb     = null;
            }


            return(Json(data, JsonRequestBehavior.AllowGet));
        }
Beispiel #19
0
 internal static Event map(booking item)
 {
     Event e = new Event();
     e.id = item.id;
     e.start = item.startDate;
     e.end = item.endDate;
     e.title = item.description;
     return e;
 }
Beispiel #20
0
        // GET: Booking/Create
        public ActionResult Create()
        {
            var roomModel = new booking();

            roomModel.roomlist = from r in db.Room
                                 where r.status == "Available"
                                 select r;

            return(View(roomModel));
        }
Beispiel #21
0
        /// <summary>
        /// Updates the booking.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="msg">The MSG.</param>
        /// <param name="status">The status.</param>
        public static void UpdateBooking(int id, string msg, string status)
        {
            string           conn          = ConnectionManager();
            LotusDataContext db            = new LotusDataContext(conn);
            booking          updateBooking = db.bookings.Where(b => b.id == id).Single <booking>();

            updateBooking.comment = msg;
            updateBooking.status  = status;
            db.SubmitChanges();
        }
Beispiel #22
0
        public ActionResult DispatchPackage(int Id)
        {
            booking booking = db.bookings.Find(Id);

            ViewBag.PackageDesc     = booking.package.packageDesc;
            ViewBag.receiverName    = booking.receiverName;
            ViewBag.RecieverAddress = booking.receiverAddress;
            ViewBag.senderName      = booking.senderName;
            return(View(booking));
        }
Beispiel #23
0
 public ActionResult Edit([Bind(Include = "id,name,phone,email,date_from,date_to,des,driver_phone,status,date_time,car_from,car_to,car_type,car_hire_type,car_size,lon1,lat1,lon2,lat2")] booking booking)
 {
     if (ModelState.IsValid)
     {
         db.Entry(booking).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(booking));
 }
Beispiel #24
0
        public ActionResult payment(booking b)
        {
            Session["cart"] = new List <booking>()
            {
                b
            };

            ModelState.Clear();
            return(View());
        }
 public ActionResult Edit([Bind(Include = "RestaurantID,BookingID,username,useremail,userphone,Dayselect,selecttime")] booking booking)
 {
     if (ModelState.IsValid)
     {
         db.Entry(booking).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.RestaurantID = new SelectList(db.restaurants, "Restaurant_id", "Restaurant_name", booking.RestaurantID);
     return(View(booking));
 }
Beispiel #26
0
        public IHttpActionResult Getbooking(int id)
        {
            booking booking = db.bookings.Find(id);

            if (booking == null)
            {
                return(NotFound());
            }

            return(Ok(booking));
        }
Beispiel #27
0
        public async Task <IHttpActionResult> Getbooking(int id)
        {
            booking booking = await db.bookings.FindAsync(id);

            if (booking == null)
            {
                return(NotFound());
            }

            return(Ok(booking));
        }
Beispiel #28
0
 internal string Payment(booking booking)
 {
     if (booking.paid == "false")
     {
         return("Visible");
     }
     else
     {
         return("Hidden");
     }
 }
Beispiel #29
0
 public ActionResult Edit([Bind(Include = "Id,customer_id,origin,destination,depart_date,return_date,trip_type,Guests")] booking booking)
 {
     if (ModelState.IsValid)
     {
         db.Entry(booking).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.customer_id = new SelectList(db.Customers, "ID", "name", booking.customer_id);
     ViewBag.trip_type   = getTripType();
     return(View(booking));
 }
Beispiel #30
0
        public IHttpActionResult Postbooking(booking booking)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.bookings.Add(booking);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = booking.id }, booking));
        }
Beispiel #31
0
        public booking SaveBooking(int booking_id)

        {
            // Recupère la réservation
            booking resa = entities.booking.Where(x => x.booking_id == booking_id).FirstOrDefault();

            // Sauvegarde les modifications
            entities.SaveChanges();

            // Retourne la réservation
            return(resa);
        }
Beispiel #32
0
        public static Reservation mapToJSON(booking item)
        {
            Reservation json = new Reservation();
            json.id = item.id;
            json.branch_fk = item.branch_fk;
            json.room_fk = item.room_fk;
            json.responsible = item.responsable;
            json.startdate = item.startDate;
            json.starttime = (item.startDate.Hour * 60) + item.startDate.Minute; // Conversao necessaria já que as horas sao usadas em minutos no client-side.
            json.endtime = (item.endDate.Hour * 60) + item.endDate.Minute;
            json.enddate = item.endDate;
            json.description = item.description;
            if (item.coffee != null)
                json.coffee = (int)item.coffee;

            return json;
        }
        public ActionResult CreateBooking(booking inBooking)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (var b = new MTEntities())
                    {
                        b.bookings.Add(inBooking);
                        b.SaveChanges();
                    }
                }

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
Beispiel #34
0
        internal static booking map(Reservation json)
        {
            booking b = new booking();
            if (json.id != null && json.id > 0)
            {
                b.id = json.id;
            }
            b.branch_fk = json.branch_fk;
            b.room_fk = json.room_fk;
            b.responsable = json.responsible;

            // Calcula o startDate (tem que pegar o dia do json.startdate e as horas do json.starttime e converter esses 2 valores em um unico DateTime)
            DateTime sd = json.startdate;
            TimeSpan tsSd = new TimeSpan(Convert.ToInt32(json.starttime / 60), Convert.ToInt32(json.starttime % 60), 0);
            sd = sd.Date + tsSd;

            // Calcula o endDate
            DateTime ed = json.enddate;
            TimeSpan tsEd = new TimeSpan(Convert.ToInt32(json.endtime / 60), Convert.ToInt32(json.endtime % 60), 0);
            sd = sd.Date + tsEd;

            b.startDate = sd;
            b.endDate = ed;
            b.description = json.description;
            if (json.coffee != null && json.coffee > 0)
                b.coffee = json.coffee;

            return b;
        }
        public ActionResult EditBooking(booking editBooking)
        {
            using (var db = new MTEntities())
            {
                try
                {

                    db.Entry(editBooking).State = EntityState.Modified;
                    db.SaveChanges();
                    return RedirectToAction("booking");
                }
                catch
                {
                    return View();
                }
            }
        }