public bool Delete(HotelReservations hotelReservation)
        {
            QuaintDatabaseManager db = new QuaintDatabaseManager(true);

            try
            {
                bool flag = false;
                db.AddParameters("HotelId", hotelReservation.HotelId);
                int affectedRows = db.ExecuteNonQuery("Delete_HotelReservation", true);

                if (affectedRows > 0)
                {
                    flag = true;
                }

                return(flag);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                db.Disconnect();
            }
        }
        private bool IsEmailExist(HotelReservations hotelReservation)
        {
            try
            {
                DataTable dtList = GetAll();
                var       rows   = dtList.AsEnumerable().Where(x => ((string)x["Email"]).ToString() == hotelReservation.Email);
                DataTable dt     = rows.Any() ? rows.CopyToDataTable() : dtList.Clone();

                if (dt != null)
                {
                    if (dt.Rows.Count > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #3
0
 protected void btnDelete_Command(object sender, CommandEventArgs e)
 {
     try
     {
         string id = Convert.ToString(e.CommandArgument);
         if (!string.IsNullOrEmpty(id))
         {
             HotelReservationBLL hotelReservationBLL = new HotelReservationBLL();
             HotelReservations   hotelReservation    = new HotelReservations();
             hotelReservation.HotelId = Convert.ToInt32(QuaintSecurityManager.Decrypt(id));
             if (hotelReservation.HotelId > 0)
             {
                 if (hotelReservationBLL.Delete(hotelReservation))
                 {
                     Alert(AlertType.Success, "Deleted successfully.");
                     LoadList();
                 }
                 else
                 {
                     Alert(AlertType.Error, "Failed to delete.");
                 }
             }
         }
     }
     catch (Exception)
     {
         Alert(AlertType.Error, "Failed to delete.");
     }
 }
        public async Task <IActionResult> PutHotelReservations([FromRoute] int id, [FromBody] HotelReservations hotelReservations)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

            _context.Entry(hotelReservations).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!HotelReservationsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
 private void txtSearch_TextChanged(object sender, EventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(txtSearch.Text))
     {
         dataGridView1.DataSource = HotelReservations.Where(r => r.Email.Contains(txtSearch.Text)).ToList();
     }
     else
     {
         dataGridView1.DataSource = HotelReservations;
     }
 }
 public bool Delete(HotelReservations hotelReservation)
 {
     try
     {
         HotelReservationDAL hotelReservationDAL = new HotelReservationDAL();
         return(hotelReservationDAL.Delete(hotelReservation));
     }
     catch (Exception)
     {
         throw;
     }
 }
        public async Task <IActionResult> PostHotelReservations([FromBody] HotelReservations hotelReservations)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.HotelReservations.Add(hotelReservations);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetHotelReservations", new { id = hotelReservations.HotelReservationId }, hotelReservations));
        }
 public static string HandleOne(string mail, HotelReservations hotelReservation)
 {
     mail = mail.Replace("-user-", hotelReservation.ApplicationUser.Name);
     mail = mail.Replace("-TypeName-", hotelReservation.HotelRooms.HotelRoomType.TypeName);
     mail = mail.Replace("-Price-", hotelReservation.HotelRooms.Price.ToString());
     mail = mail.Replace("-HotelName-", hotelReservation.HotelRooms.Hotel.Name);
     mail = mail.Replace("-Address-", hotelReservation.HotelRooms.Hotel.Address);
     mail = mail.Replace("-Tel1-", hotelReservation.HotelRooms.Hotel.Tel1);
     mail = mail.Replace("-ReservationDate-", hotelReservation.ReservationDate.ToString());
     mail = mail.Replace("-StartDate-", hotelReservation.StartDate.ToString());
     mail = mail.Replace("-EndDate-", hotelReservation.EndDate.ToString());
     mail = mail.Replace("-PaymentType-", hotelReservation.PaymentType.ToString());
     return(mail);
 }
        public void Setup()
        {
            // Runs before each test. (Optional
            this.hotelService = new HotelReservations();
            customerTypeRate.Add(CustomerType.REGULAR, new Rate(110, 90));
            customerTypeRate.Add(CustomerType.REWARD, new Rate(80, 80));
            lakewood = new Hotel("Lakewood", 3, customerTypeRate);

            customerTypeRate = new Dictionary <CustomerType, Rate>();
            customerTypeRate.Add(CustomerType.REGULAR, new Rate(160, 40));
            customerTypeRate.Add(CustomerType.REWARD, new Rate(110, 50));
            bridgewood = new Hotel("Bridgewood", 4, customerTypeRate);

            customerTypeRate = new Dictionary <CustomerType, Rate>();
            customerTypeRate.Add(CustomerType.REGULAR, new Rate(220, 150));
            customerTypeRate.Add(CustomerType.REWARD, new Rate(100, 40));
            ridgewood = new Hotel("Ridgewood", 5, customerTypeRate);
        }
Exemple #10
0
        public ActionResult Booking(HotelReservations reservation)
        {
            if (ModelState.IsValid)
            {
                if (reservation.Id == 0)
                {
                    _db.HotelReservations.Add(new HotelReservations()
                    {
                        ApplicationUserId = ApplicationUserService.GetUserId(),
                        EndDate           = reservation.EndDate,
                        HotelRoomsId      = reservation.HotelRoomsId,
                        PaymentType       = reservation.PaymentType,
                        StartDate         = reservation.StartDate,
                        ReservationDate   = DateTime.Now
                    });
                    _db.SaveChanges();
                    var body =
                        $"{MailService.HandleOne(FileService.ReadFile(Server.MapPath("~/Files/Emails/1.txt")), new HotelReservations() {EndDate = reservation.EndDate, PaymentType = reservation.PaymentType, StartDate = reservation.StartDate, ReservationDate = DateTime.Now, ApplicationUser = ApplicationUserService.GetUser(), HotelRooms = _db.HotelRooms.FirstOrDefault(l => l.Id == reservation.HotelRoomsId),})}";
                    MailService.SendMail(Services.ApplicationUserService.GetUser().Email,
                                         "Booking Confirmation", body);
                    return(View("BookingConfirm"));
                }
                else
                {
                    var currentUser = ApplicationUserService.GetUserId();
                    var hotelRes    = _db.HotelReservations.FirstOrDefault(l =>
                                                                           l.Id == reservation.Id && l.ApplicationUserId == currentUser);
                    if (hotelRes != null)
                    {
                        hotelRes.EndDate          = reservation.EndDate;
                        hotelRes.HotelRoomsId     = reservation.HotelRoomsId;
                        hotelRes.PaymentType      = reservation.PaymentType;
                        hotelRes.StartDate        = reservation.StartDate;
                        _db.Entry(hotelRes).State = EntityState.Modified;
                        _db.SaveChanges();
                    }

                    return(RedirectToAction("Profile", "Manage"));
                }
            }

            return(RedirectToAction("Booking", new { Room = reservation.HotelRoomsId }));
        }
        public bool Update(HotelReservations hotelReservation)
        {
            QuaintDatabaseManager db = new QuaintDatabaseManager(true);

            try
            {
                bool flag = false;
                db.AddParameters("HotelId", hotelReservation.HotelId);
                db.AddParameters("HotelCode", hotelReservation.HotelCode);
                db.AddParameters("HotelName", hotelReservation.HotelName);
                db.AddParameters("ArrivalDate", hotelReservation.ArrivalDate);
                db.AddParameters("DepartureDate", hotelReservation.DepartureDate);
                db.AddParameters("RoomType", hotelReservation.RoomType);
                db.AddParameters("BookedBy", hotelReservation.BookedBy);
                db.AddParameters("Email", hotelReservation.Email);
                db.AddParameters("ContactNumber", hotelReservation.ContactNumber);
                db.AddParameters("Address", hotelReservation.Address);
                db.AddParameters("IsActive", hotelReservation.IsActive);
                db.AddParameters("CreatedDate", ((hotelReservation.CreatedDate == null) ? hotelReservation.CreatedDate : hotelReservation.CreatedDate.Value));
                db.AddParameters("CreatedBy", hotelReservation.CreatedBy);
                db.AddParameters("CreatedFrom", hotelReservation.CreatedFrom);
                db.AddParameters("UpdatedDate", ((hotelReservation.UpdatedDate == null) ? hotelReservation.UpdatedDate : hotelReservation.UpdatedDate.Value));
                db.AddParameters("UpdatedBy", hotelReservation.UpdatedBy);
                db.AddParameters("UpdatedFrom", hotelReservation.UpdatedFrom);
                int affectedRows = db.ExecuteNonQuery("Update_hotelReservation", true);

                if (affectedRows > 0)
                {
                    flag = true;
                }

                return(flag);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                db.Disconnect();
            }
        }
Exemple #12
0
        protected void btnConfirm_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txtHotelName.Text))
                {
                    Alert(AlertType.Warning, "Enter hotel name.");
                    txtHotelName.Focus();
                }
                else if (string.IsNullOrEmpty(txtArrivalDate.Text))
                {
                    Alert(AlertType.Warning, "Enter date of arrival.");
                    txtArrivalDate.Focus();
                }
                else if (string.IsNullOrEmpty(txtDepartureDate.Text))
                {
                    Alert(AlertType.Warning, "Enter date of departure.");
                    txtDepartureDate.Focus();
                }
                else if (string.IsNullOrEmpty(txtRoomType.Text))
                {
                    Alert(AlertType.Warning, "Enter room type.");
                    txtRoomType.Focus();
                }
                else if (string.IsNullOrEmpty(txtBookedBy.Text))
                {
                    Alert(AlertType.Warning, "Enter booked by name.");
                    txtBookedBy.Focus();
                }
                else if (string.IsNullOrEmpty(txtContactNumber.Text))
                {
                    Alert(AlertType.Warning, "Enter contact number.");
                    txtContactNumber.Focus();
                }
                else
                {
                    QuaintLibraryManager lib = new QuaintLibraryManager();
                    string   hotelName       = Convert.ToString(txtHotelName.Text);
                    DateTime arrivalDate     = Convert.ToDateTime(txtArrivalDate.Text);
                    DateTime departureDate   = Convert.ToDateTime(txtDepartureDate.Text);
                    string   roomType        = Convert.ToString(txtRoomType.Text);
                    string   bookedBy        = Convert.ToString(txtBookedBy.Text);
                    string   email           = Convert.ToString(txtEmail.Text);
                    string   contactNumber   = Convert.ToString(txtContactNumber.Text);
                    string   address         = Convert.ToString(txtAddress.Text);


                    HotelReservationBLL hotelReservationBLL = new HotelReservationBLL();
                    HotelReservations   hotelReservation    = new HotelReservations();
                    hotelReservation.HotelCode     = this.ModelCode;
                    hotelReservation.HotelName     = hotelName;
                    hotelReservation.ArrivalDate   = arrivalDate;
                    hotelReservation.DepartureDate = departureDate;
                    hotelReservation.RoomType      = roomType;
                    hotelReservation.BookedBy      = roomType;
                    hotelReservation.Email         = email;
                    hotelReservation.ContactNumber = contactNumber;
                    hotelReservation.Address       = address;
                    hotelReservation.IsActive      = true;
                    hotelReservation.CreatedDate   = DateTime.Now;
                    hotelReservation.CreatedBy     = this.UserInfo;
                    hotelReservation.CreatedFrom   = this.StationInfo;

                    //DataTable dtAvailableRoom = hotelReservationBLL.GetAllActive();
                    //int totalAvailableRoom = dtAvailableRoom.Rows.Count;
                    if (hotelReservationBLL.Save(hotelReservation))
                    {
                        //Alert(AlertType.Success, "Saved successfully.");
                        Alert(AlertType.Success, "Saved successfully.");
                        ClearFields();
                        GenerateCode();

                        Response.Redirect("~/Pages/HotelReservation.aspx?Ref=success", false);
                    }
                    else
                    {
                        Alert(AlertType.Error, "Failed to save.");
                    }
                }
            }

            catch (Exception ex)
            {
                Alert(AlertType.Error, ex.Message.ToString());
            }
        }
Exemple #13
0
        protected void btnActiveOrDeactive_Command(object sender, CommandEventArgs e)
        {
            try
            {
                string id = Convert.ToString(e.CommandArgument);
                if (!string.IsNullOrEmpty(id))
                {
                    HotelReservationBLL hotelReservationBLL = new HotelReservationBLL();
                    DataTable           dt = hotelReservationBLL.GetById(Convert.ToInt32(QuaintSecurityManager.Decrypt(id)));
                    if (dt != null)
                    {
                        if (dt.Rows.Count > 0)
                        {
                            string            actionStatus     = "Updated";
                            HotelReservations hotelReservation = new HotelReservations();
                            hotelReservation.HotelId       = Convert.ToInt32(Convert.ToString(dt.Rows[0]["HotelId"]));
                            hotelReservation.HotelCode     = Convert.ToString(dt.Rows[0]["HotelCode"]);
                            hotelReservation.HotelName     = Convert.ToString(dt.Rows[0]["HotelName"]);
                            hotelReservation.ArrivalDate   = Convert.ToDateTime(dt.Rows[0]["ArrivalDate"]);
                            hotelReservation.DepartureDate = Convert.ToDateTime(dt.Rows[0]["DepartureDate"]);
                            hotelReservation.RoomType      = Convert.ToString(dt.Rows[0]["RoomType"]);
                            hotelReservation.BookedBy      = Convert.ToString(dt.Rows[0]["BookedBy"]);
                            hotelReservation.Email         = Convert.ToString(dt.Rows[0]["Email"]);
                            hotelReservation.ContactNumber = Convert.ToString(dt.Rows[0]["ContactNumber"]);
                            hotelReservation.Address       = Convert.ToString(dt.Rows[0]["Address"]);
                            hotelReservation.IsActive      = Convert.ToBoolean(Convert.ToString(dt.Rows[0]["IsActive"]));
                            hotelReservation.CreatedDate   = (string.IsNullOrEmpty(Convert.ToString(dt.Rows[0]["CreatedDate"]))) ? (DateTime?)null : Convert.ToDateTime(Convert.ToString(dt.Rows[0]["CreatedDate"]));
                            hotelReservation.CreatedBy     = Convert.ToString(dt.Rows[0]["CreatedBy"]);
                            hotelReservation.CreatedFrom   = Convert.ToString(dt.Rows[0]["CreatedFrom"]);

                            hotelReservation.UpdatedDate = DateTime.Now;
                            hotelReservation.UpdatedBy   = UserInfo;
                            hotelReservation.UpdatedFrom = StationInfo;

                            if (hotelReservation.IsActive)
                            {
                                hotelReservation.IsActive = false;
                                actionStatus = "Deactivated";
                            }
                            else
                            {
                                hotelReservation.IsActive = true;
                                actionStatus = "Activated";
                            }

                            if (hotelReservationBLL.Update(hotelReservation))
                            {
                                Alert(AlertType.Success, actionStatus + " successfully.");
                                LoadList();
                            }
                            else
                            {
                                Alert(AlertType.Error, "Failed to update.");
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                Alert(AlertType.Error, "Failed to process.");
            }
        }