/// <summary>
        ///     Handles the Click event of the _btnSearch control.
        /// </summary>
        /// <param name = "sender">The source of the event.</param>
        /// <param name = "e">The <see cref = "System.EventArgs" /> instance containing the event data.</param>
        protected void _btnSearch_Click(object sender, EventArgs e)
        {
            if (_txtZip.Text.Trim() == String.Empty && _cbCity.SelectedValue == "NULL" && _cbState.SelectedValue == "NULL")
            {
                WriteFeedBackMaster(FeedbackType.Warning, "Please select at least one field to search by");
                return;
            }

            var zip       = _txtZip.Text.Trim() != String.Empty ? _txtZip.Text.Trim() : String.Empty;
            var city      = _cbCity.SelectedValue != "NULL" ? _cbCity.SelectedValue : String.Empty;
            var state     = _cbState.SelectedValue != "NULL" ? _cbState.SelectedValue : String.Empty;
            var startDate = (DateTime?)_rdpStart.DbSelectedDate;
            var endDate   = (DateTime?)_rdpEnd.DbSelectedDate;

            var db = new UrbanDataContext();
            //Loads all rooms based on search queries
            var list = db.Manager.Room.GetAllForSearch(zip, city, state, startDate, endDate);

            _rgSearchResults.DataSource = list;
            _rgSearchResults.Rebind();

            if (list.Count <= 0)
            {
                return;
            }
            _btnViewResultsOnMap.Visible = true;
            _btnViewResultsOnMap.Enabled = true;
        }
        /// <summary>
        ///     Handles the Click event of the _viewResultsOnMap control.
        /// </summary>
        /// <param name = "sender">The source of the event.</param>
        /// <param name = "e">The <see cref = "System.EventArgs" /> instance containing the event data.</param>
        protected void _viewResultsOnMap_Click(object sender, EventArgs e)
        {
            var results = new Dictionary <Building, List <Room> >();
            var db      = new UrbanDataContext();

            foreach (GridDataItem item in _rgSearchResults.Items)
            {
                int itemId;
                if (!int.TryParse(item["Id"].Text, out itemId) || itemId <= 0)
                {
                    continue;
                }

                var         r = db.Manager.Room.GetByKey(itemId);
                List <Room> rList;
                if (results.TryGetValue(r.Building, out rList) && rList != null)
                {
                    rList.Add(r);
                    results[r.Building] = rList;
                }
                else
                {
                    results[r.Building] = new List <Room> {
                        r
                    };
                }
            }

            var buldingObj = results.Select(r => new BuildingSerialObj(r.Key, r.Value)).ToList();
            var jsonString = buldingObj.ToJson();

            RadAjaxManager.GetCurrent(Page).ResponseScripts.Add(String.Format("return ShowResults('{0}','{1}');", jsonString, true));
        }
        /// <summary>
        ///     Handles the Click event of the _btnSave control.
        /// </summary>
        /// <param name = "sender">The source of the event.</param>
        /// <param name = "e">The <see cref = "System.EventArgs" /> instance containing the event data.</param>
        protected void _btnSaveRoom_Click(object sender, EventArgs e)
        {
            var db   = new UrbanDataContext();
            var room = db.Manager.Room.GetByKey(RoomId);

            if (room == null)
            {
                throw new Exception("Room Is Null");
            }

            if (!Page.IsValid || !ValidateInputs())
            {
                return;
            }

            room.Title        = _txtRoomTitle.Text.Trim();
            room.MaxOccupancy = int.Parse(_txtMaxOccupancy.Text);
            room.RoomTypeID   = int.Parse(_cbRoomType.SelectedValue);
            room.Number       = _txtRoomNumber.Text;
            room.BuildingID   = int.Parse(_cbBuilding.SelectedValue);
            room.Description  = _rContent.Content;

            db.SubmitChanges();
            RadAjaxManager.GetCurrent(Page).Redirect(String.Format("~/App/Pages/MyAccount.aspx?message={0}&messageType={1}", "Room saved", FeedbackType.Success));
        }
Example #4
0
        /// <summary>
        ///     Processes the building creation.
        /// </summary>
        /// <param name = "db">The db.</param>
        /// <param name = "userId">The user id.</param>
        /// <param name = "params">The @params.</param>
        /// <returns></returns>
        public static int ProcessBuildingCreation(ref UrbanDataContext db, int userId, ProcessBuildingCreationParams @params)
        {
            //Check if already exists then return buidling Id
            var existingBuilding = DoesBuildingAlreadyExist(ref db, @params.PrimaryAddress, @params.SecondaryAddress, @params.City, @params.Zip, @params.State, userId);

            if (existingBuilding != null)
            {
                return(existingBuilding.Id);
            }

            //Check if valid if not return -1
            if (DoesBuildingAlreadyExistNotForUser(ref db, @params.PrimaryAddress, @params.SecondaryAddress, @params.City, @params.Zip, @params.State, userId))
            {
                return(-1);
            }

            //create new building then return new building id
            var building = new Building
            {
                PrimaryAddress   = @params.PrimaryAddress,
                SecondaryAddress = @params.SecondaryAddress,
                City             = @params.City,
                Zip    = @params.Zip,
                State  = @params.State,
                Name   = @params.Name,
                UserID = userId
            };

            db.Building.InsertOnSubmit(building);
            db.SubmitChanges();
            return(building.Id);
        }
        /// <summary>
        ///     Handles the NeedDataSource event of the _rgMyBuildings control.
        /// </summary>
        /// <param name = "sender">The source of the event.</param>
        /// <param name = "e">The <see cref = "Telerik.Web.UI.GridNeedDataSourceEventArgs" /> instance containing the event data.</param>
        protected void _rgReservations_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            var db   = new UrbanDataContext();
            var list = db.Manager.RoomReservation.GetAllForSearch(Cu.Id, _rTabReservations.SelectedTab.Value == "Open" ? true : false);

            _rgReservations.DataSource = list;
        }
        /// <summary>
        ///     Handles the OnNavigationComplete event of the _rsReservations control.
        /// </summary>
        /// <param name = "sender">The source of the event.</param>
        /// <param name = "e">The <see cref = "Telerik.Web.UI.SchedulerNavigationCompleteEventArgs" /> instance containing the event data.</param>
        protected void _rsReservations_OnNavigationComplete(object sender, SchedulerNavigationCompleteEventArgs e)
        {
            var db           = new UrbanDataContext();
            var selectedDate = _rsReservations.SelectedDate;

            switch (Type)
            {
            case 1:
            {
                Appointments = AppointmentUtilities.GetAppointmentObjectsByDateRangeAndRoomId(ref db, new DateTime(selectedDate.Year, selectedDate.Month, 1), new DateTime(selectedDate.Year, selectedDate.Month, 1).AddMonths(1).AddDays(-1), Utilities.GetQueryStringInt("roomId"));
                break;
            }

            case 2:
            {
                Appointments = AppointmentUtilities.GetAllReservedObjectsByDateRangeAndUserId(ref db, new DateTime(selectedDate.Year, selectedDate.Month, 1), new DateTime(selectedDate.Year, selectedDate.Month, 1).AddMonths(1).AddDays(-1), Cu.Id);
                break;
            }

            case 3:
            {
                Appointments = AppointmentUtilities.GetAllReservedObjectsByReservationId(ref db, Utilities.GetQueryStringInt("RoomReservationID"));
                break;
            }
            }

            _rsReservations.DataSource = Appointments;
            _rsReservations.Rebind();
        }
Example #7
0
        /// <summary>
        /// Creates the user.
        /// </summary>
        /// <param name="info">The info.</param>
        /// <param name="password">The password.</param>
        /// <returns></returns>
        public static bool CreateUser(User info, string password)
        {
            var db = new UrbanDataContext();

            //User Item
            var u = new User
            {
                ActivationGuid = info.ActivationGuid,
                City           = info.City,
                DateCreated    = DateTime.Now,
                Email          = info.Email,
                FirstName      = info.FirstName,
                LastName       = info.LastName,
                IsAdmin        = false,
                PhoneNumber    = info.PhoneNumber,
                PrimaryAddress = info.PrimaryAddress,
                Zip            = info.Zip
            };

            string passSalt     = CreateSalt();
            string passwordHash = CreatePasswordHash(password, passSalt);

            u.Password     = passwordHash;
            u.PasswordSalt = passSalt;
            db.User.InsertOnSubmit(u);
            db.SubmitChanges();

            //Send Email With firm information user ID, and the new password.
            //User_EmailTemplate.NewUserAccount(u.Id, (int)c.FirmID, password);

            return(true);
        }
Example #8
0
        /// <summary>
        ///     Handles the Load event of the Page control.
        /// </summary>
        /// <param name = "sender">The source of the event.</param>
        /// <param name = "e">The <see cref = "System.EventArgs" /> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack)
            {
                return;
            }

            RoomId = Utilities.GetQueryStringInt("RoomId");
            if (RoomId <= 0)
            {
                RadAjaxManager.GetCurrent(Page).Redirect("~/Default.aspx?message=Invalid room");
            }
            var db   = new UrbanDataContext();
            var room = db.Manager.Room.GetByKey(RoomId);



            if (CurrentUserUtilities.GetCuIdSafely() <= 0 || room == null || room.UserID != Cu.Id)
            {
                RadAjaxManager.GetCurrent(Page).Redirect("~/Default.aspx?message=Invalid room");
                return;
            }

            _txtRoomNumber.Text   = room.Number;
            _txtBuildingName.Text = room.Building.Name;
        }
        /// <summary>
        ///     Raises the <see cref = "E:System.Web.UI.Control.Init" /> event to initialize the page.
        /// </summary>
        /// <param name = "e">An <see cref = "T:System.EventArgs" /> that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            if (!IsPostBack)
            {
                var db = new UrbanDataContext();
                //Gets the first and last day for the month
                switch (Type)
                {
                case 1:
                {
                    ViewState["Appointments"] = AppointmentUtilities.GetAppointmentObjectsByDateRangeAndRoomId(ref db, new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1), new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddMonths(1).AddDays(-1), Utilities.GetQueryStringInt("roomId"));
                    Page.Title = "Room Details";
                    break;
                }

                case 2:
                {
                    ViewState["Appointments"] = AppointmentUtilities.GetAllReservedObjectsByDateRangeAndUserId(ref db, new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1), new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddMonths(1).AddDays(-1), Cu.Id);
                    Page.Title = "Up Comming Events";
                    break;
                }

                case 3:
                {
                    ViewState["Appointments"] = AppointmentUtilities.GetAllReservedObjectsByReservationId(ref db, Utilities.GetQueryStringInt("RoomReservationID"));
                    Page.Title = "Reservation";
                    break;
                }
                }
            }
            _rsReservations.DataSource = Appointments;
        }
        /// <summary>
        ///     Handles the Load event of the Page control.
        /// </summary>
        /// <param name = "sender">The source of the event.</param>
        /// <param name = "e">The <see cref = "System.EventArgs" /> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            BuildingId = Utilities.GetQueryStringInt("BuildingId");

            InitPage(BuildingId > 0 ? "Edit Building Details" : "Create Building", MainTabs.MyAccount);

            if (Page.IsPostBack)
            {
                return;
            }

            if (BuildingId < 0)
            {
                RadAjaxManager.GetCurrent(Page).Redirect(String.Format("~/Default.aspx?message={0}&messageType={1}", "Invalid Building", FeedbackType.Error));
            }
            var db       = new UrbanDataContext();
            var building = db.Manager.Building.GetByKey(BuildingId);

            if (CurrentUserUtilities.GetCuIdSafely() <= 0 || (building != null && building.UserID != Cu.Id))
            {
                RadAjaxManager.GetCurrent(Page).Redirect(String.Format("~/Default.aspx?message={0}&messageType={1}", "Invalid Building", FeedbackType.Error));
            }
            _cbState.LoadXml(Utilities.GetXmlForPath(Utilities.StatePathWithNoneXml));
            LoadPageFields(building);
        }
Example #11
0
        /// <summary>
        ///     Handles the Load event of the Page control.
        /// </summary>
        /// <param name = "sender">The source of the event.</param>
        /// <param name = "e">The <see cref = "System.EventArgs" /> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            InitPage("Room Details", MainTabs.FindARoom);

            if (CurrentUserUtilities.GetCuIdSafely() <= 0)
            {
                RadToolTip1.Enabled      = false;
                _rRating.ReadOnly        = true;
                _rsReservations.ReadOnly = true;
            }

            if (Page.IsPostBack)
            {
                return;
            }

            RoomId = Utilities.GetQueryStringInt("RoomId");
            if (RoomId <= 0)
            {
                RadAjaxManager.GetCurrent(Page).Redirect("~/Default.aspx?message=Invalid room");
            }
            var db   = new UrbanDataContext();
            var room = db.Manager.Room.GetByKey(RoomId);

            if (room == null)
            {
                RadAjaxManager.GetCurrent(Page).Redirect("~/Default.aspx?message=Invalid room");
            }

            LoadPageFields(room);
        }
Example #12
0
        /// <summary>
        ///     Handles the NeedDataSource event of the _rgAvailableTimes control.
        /// </summary>
        /// <param name = "sender">The source of the event.</param>
        /// <param name = "e">The <see cref = "Telerik.Web.UI.GridNeedDataSourceEventArgs" /> instance containing the event data.</param>
        protected void _rgAvailableTimes_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            var db       = new UrbanDataContext();
            var roomList = db.Manager.RoomAvailability.GetByRoomID(RoomId).OrderByDescending(t => t.StartDate).ToList();

            _rgAvailableTimes.DataSource = roomList;
        }
Example #13
0
        /// <summary>
        /// Handles the ItemCommand event of the _rgAvailableTimes control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Telerik.Web.UI.GridCommandEventArgs"/> instance containing the event data.</param>
        protected void _rgAvailableTimes_ItemCommand(object sender, GridCommandEventArgs e)
        {
            switch (e.CommandName)
            {
            case "Delete":
            {
                var r = e.Item as GridDataItem;
                int itemId;

                if (r != null && int.TryParse(r["Id"].Text, out itemId))
                {
                    var db   = new UrbanDataContext();
                    var date = db.Manager.RoomAvailability.GetByKey(itemId);

                    if (date != null)
                    {
                        db.RoomAvailability.DeleteOnSubmit(date);
                        db.SubmitChanges();
                        WriteFeedBackMaster(FeedbackType.Success, "Date deleted");
                        RebindGridAndScheduler();
                    }
                }
                break;
            }
            }
        }
Example #14
0
        /// <summary>
        ///     Handles the SelectedIndexChanged event of the _cbBuilding control.
        /// </summary>
        /// <param name = "sender">The source of the event.</param>
        /// <param name = "e">The <see cref = "Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs" /> instance containing the event data.</param>
        protected void _cbBuilding_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            int itemId;

            if (!int.TryParse(e.Value, out itemId) || itemId <= 0)
            {
                return;
            }
            var db       = new UrbanDataContext();
            var building = db.Manager.Building.GetByKey(itemId);

            if (building == null)
            {
                throw new NullReferenceException("building is null with itemId : " + itemId);
            }

            _txtPrimaryAddress.Text   = building.PrimaryAddress;
            _txtSecondaryAddress.Text = building.SecondaryAddress;
            _txtCity.Text             = building.City;
            _txtZip.Text          = building.Zip;
            _txtBuildingName.Text = building.Name;

            var li = _cbState.FindItemByValue(building.State);

            if (li != null)
            {
                li.Selected = true;
            }
        }
Example #15
0
        /// <summary>
        ///     Verifies the required fields selected.
        /// </summary>
        /// <returns></returns>
        private int VerifyRequiredFieldsSelected()
        {
            //Verify Room Values
            if (_txtRoomNumber.Text.Trim() == String.Empty || _txtRoomTitle.Text.Trim() == String.Empty || _txtMaxOccupancy.Text == String.Empty || _cbRoomType.SelectedValue == "NULL")
            {
                return(-1);
            }
            if (_txtPrimaryAddress.Text.Trim() == String.Empty || _txtCity.Text.Trim() == String.Empty || _txtZip.Text.Trim() == String.Empty || _cbState.SelectedValue == "NULL")
            {
                return(-1);
            }

            var db = new UrbanDataContext();

            //Building Exists for another user check
            if (BuildingUtilities.DoesBuildingAlreadyExistNotForUser(ref db, _txtPrimaryAddress.Text.Trim(), _txtSecondaryAddress.Text.Trim(), _txtCity.Text.Trim(), _txtZip.Text.Trim(), _cbState.SelectedValue, Cu.Id))
            {
                return(-2);
            }

            var existingBuilding = BuildingUtilities.DoesBuildingAlreadyExist(ref db, _txtPrimaryAddress.Text.Trim(), _txtSecondaryAddress.Text.Trim(), _txtCity.Text.Trim(), _txtZip.Text.Trim(), _cbState.SelectedValue, Cu.Id);

            if (existingBuilding != null)
            {
                //return existingBuilding.Id;
                if (RoomUtilities.DoesRoomExistWithNumber(ref db, existingBuilding.Id, _txtRoomNumber.Text.Trim()))
                {
                    return(-3);
                }
            }

            return(1);
        }
Example #16
0
        /// <summary>
        ///     Handles the NeedDataSource event of the _rgAvailableTimes control.
        /// </summary>
        /// <param name = "sender">The source of the event.</param>
        /// <param name = "e">The <see cref = "Telerik.Web.UI.GridNeedDataSourceEventArgs" /> instance containing the event data.</param>
        protected void _rgRequestedTimes_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            var db      = new UrbanDataContext();
            var results = db.Manager.RoomReservationDates.GetByRoomReservationID(RoomReservationId).ToList();

            _rgRequestedTimes.DataSource = results;
        }
Example #17
0
        /// <summary>
        ///     Handles the NeedDataSource event of the _rgMyBuildings control.
        /// </summary>
        /// <param name = "sender">The source of the event.</param>
        /// <param name = "e">The <see cref = "Telerik.Web.UI.GridNeedDataSourceEventArgs" /> instance containing the event data.</param>
        protected void _rgMyBuildings_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            var db   = new UrbanDataContext();
            var list = db.Manager.Building.GetByUserID(Cu.Id).ToList();

            _rgMyBuildings.DataSource = list;
        }
Example #18
0
        /// <summary>
        ///     Handles the Click event of the btnPostComment control.
        /// </summary>
        /// <param name = "sender">The source of the event.</param>
        /// <param name = "e">The <see cref = "System.EventArgs" /> instance containing the event data.</param>
        protected void btnPostComment_Click(object sender, EventArgs e)
        {
            //Will insert comments about the site here.
            if (txtComments.Text != String.Empty)
            {
                if (_litComments.Text == "Your Comments")
                {
                    _litComments.Text = string.Empty;
                }
                _litComments.Text = _litComments.Text + "Rating: <strong>" + LastRating + "</strong> <p>" + txtComments.Text + "</p><br/>";

                //Create Comment Object
                var roomRating = new RoomComments
                {
                    Comments   = txtComments.Text,
                    RoomID     = RoomId,
                    UserID     = Cu.Id,
                    Score      = LastRating,
                    DatePosted = DateTime.Now
                };
                var db = new UrbanDataContext();
                db.RoomComments.InsertOnSubmit(roomRating);
                db.SubmitChanges();
                //Redirect to same page with comment success
                RadAjaxManager.GetCurrent(Page).Redirect(String.Format("RoomDetails.aspx?roomId={0}&message={1}", RoomId, "Comment successfully submitted."));
            }

            //Close tooltip

            RadAjaxManager.GetCurrent(Page).ResponseScripts.Add("CloseToolTip1();");
        }
Example #19
0
        /// <summary>
        ///     Builds the comments for room.
        /// </summary>
        /// <param name = "roomId">The room id.</param>
        /// <returns></returns>
        public static string BuildCommentsForRoom(int roomId)
        {
            var sb          = new StringBuilder();
            var db          = new UrbanDataContext();
            var commentList = db.Manager.RoomComments.GetByRoomID(roomId).OrderByDescending(t => t.DatePosted);
            var count       = 0;

            foreach (var c in commentList)
            {
                if (count > 0)
                {
                    sb.Append("<br />");
                }
                sb.Append(String.Format("<strong>Rating: {0} / 5 </strong><br />", c.Score));
                if (c.DatePosted != null)
                {
                    sb.AppendLine(String.Format("<strong>Date Posted: {0} </strong><br />", ((DateTime)c.DatePosted).ToShortDateString()));
                }
                sb.AppendLine(String.Format("<strong>Comments:</strong> {0}<br />", c.Comments));
                count++;
            }


            return(sb.ToString());
        }
        /// <summary>
        ///     Handles the NeedDataSource event of the RadGrid1 control.
        /// </summary>
        /// <param name = "source">The source of the event.</param>
        /// <param name = "e">The <see cref = "Telerik.Web.UI.GridNeedDataSourceEventArgs" /> instance containing the event data.</param>
        protected void _rgImages_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
        {
            //RadGrid1.DataSource = DataSource;
            var db    = new UrbanDataContext();
            var files = db.Manager.RoomImageLink.GetByRoomID(RoomId).ToList();

            _rgImages.DataSource = files;
        }
Example #21
0
        protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            var db      = new UrbanDataContext();
            var manager = new UrbanDataManager(db);

            RadGrid1.DataSource = (from u in db.User
                                   select u).ToList();
        }
Example #22
0
        /// <summary>
        ///     Handles the OnNavigationComplete event of the _rsReservations control.
        /// </summary>
        /// <param name = "sender">The source of the event.</param>
        /// <param name = "e">The <see cref = "Telerik.Web.UI.SchedulerNavigationCompleteEventArgs" /> instance containing the event data.</param>
        protected void _rsReservations_OnNavigationComplete(object sender, SchedulerNavigationCompleteEventArgs e)
        {
            var db           = new UrbanDataContext();
            var selectedDate = _rsReservations.SelectedDate;

            Appointments = AppointmentUtilities.GetAppointmentObjectsByDateRangeAndRoomId(ref db, new DateTime(selectedDate.Year, selectedDate.Month, 1), new DateTime(selectedDate.Year, selectedDate.Month, 1).AddMonths(1).AddDays(-1), Utilities.GetQueryStringInt("roomId")).ToList();
            _rsReservations.DataSource = Appointments;
            _rsReservations.Rebind();
        }
Example #23
0
        /// <summary>
        ///     Handles the Click event of the _btnViewLocation control. <br />
        ///     Turns the address into json object and passes to javascript function on page.
        /// </summary>
        /// <param name = "sender">The source of the event.</param>
        /// <param name = "e">The <see cref = "System.EventArgs" /> instance containing the event data.</param>
        protected void _btnViewLocation_Click(object sender, EventArgs e)
        {
            var db       = new UrbanDataContext();
            var room     = db.Manager.Room.GetByKey(RoomId);
            var building = new BuildingSerialObj(room);
            var address  = building.ToJson();

            RadAjaxManager.GetCurrent(Page).ResponseScripts.Add(String.Format("return ShowAddressLocation('{0}');", address));
        }
Example #24
0
        /// <summary>
        /// Rebinds the grid and scheduler.
        /// </summary>
        private void RebindGridAndScheduler()
        {
            _rgAvailableTimes.Rebind();
            var db           = new UrbanDataContext();
            var selectedDate = _rsReservations.SelectedDate;

            Appointments = RoomAvailabilityUtilities.GetAppointmentObjsWithRecurring(ref db, new DateTime(selectedDate.Year, selectedDate.Month, 1), new DateTime(selectedDate.Year, selectedDate.Month, 1).AddMonths(1).AddDays(-1), Utilities.GetQueryStringInt("roomId")).ToList();
            _rsReservations.DataSource = Appointments;
        }
Example #25
0
        /// <summary>
        ///     Handles the OnNavigationComplete event of the _rsReservations control.
        /// </summary>
        /// <param name = "sender">The source of the event.</param>
        /// <param name = "e">The <see cref = "Telerik.Web.UI.SchedulerNavigationCompleteEventArgs" /> instance containing the event data.</param>
        protected void _rsReservations_OnNavigationComplete(object sender, SchedulerNavigationCompleteEventArgs e)
        {
            var db           = new UrbanDataContext();
            var selectedDate = _rsReservations.SelectedDate;

            ViewState["Appointments"]  = AppointmentUtilities.GetAllReservedObjectsByReservationId(ref db, RoomReservationId);
            _rsReservations.DataSource = Appointments;
            _rsReservations.Rebind();
        }
 /// <summary>
 ///     Raises the <see cref = "E:System.Web.UI.Control.Init" /> event to initialize the page.
 /// </summary>
 /// <param name = "e">An <see cref = "T:System.EventArgs" /> that contains the event data.</param>
 protected override void OnInit(EventArgs e)
 {
     base.OnInit(e);
     if (!IsPostBack)
     {
         var db = new UrbanDataContext();
         ViewState["Appointments"] = AppointmentUtilities.GetAppointmentObjectsByDateRangeAndRoomId(ref db, new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1), new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddMonths(1).AddDays(-1), Utilities.GetQueryStringInt("roomId"));
     }
     _rsReservations.DataSource = Appointments;
 }
Example #27
0
 /// <summary>
 ///     Raises the <see cref = "E:System.Web.UI.Control.Init" /> event to initialize the page.
 /// </summary>
 /// <param name = "e">An <see cref = "T:System.EventArgs" /> that contains the event data.</param>
 protected override void OnInit(EventArgs e)
 {
     base.OnInit(e);
     if (!IsPostBack)
     {
         var db = new UrbanDataContext();
         ViewState["Appointments"] = AppointmentUtilities.GetAllReservedObjectsByReservationId(ref db, Utilities.GetQueryStringInt("RoomReservationID"));
     }
     _rsReservations.DataSource = Appointments;
 }
Example #28
0
        /// <summary>
        ///     Logins the specified user name.
        /// </summary>
        /// <param name = "userName">Name of the user.</param>
        /// <param name = "password">The password.</param>
        /// <returns></returns>
        public static bool Login(string userName, string password)
        {
            var db = new UrbanDataContext();
            var c  = db.Manager.User.GetUserByEmail(userName);

            if (c != null && c.IsUserAuthenticated != null && (bool)c.IsUserAuthenticated)
            {
                return(DoesPassMatch(password, c.PasswordSalt, c.Password));
            }
            return(false);
        }
        public string ListUsers()
        {
            var         db             = new UrbanDataContext();
            string      UserListString = "";
            List <User> usersList      = (from u in db.User select u).ToList();

            foreach (User user in usersList)
            {
                UserListString += user.Id + ";";
            }
            return(UserListString);
        }
Example #30
0
        /// <summary>
        /// Handles the Click event of the _btnAddDates control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void _btnAddDates_Click(object sender, EventArgs e)
        {
            var startDate = (DateTime)_rdpStartDate.DbSelectedDate;
            var startTime = ((DateTime)_rtpStartTime.DbSelectedDate).TimeOfDay;
            var endDate   = _rdpEndDate.DbSelectedDate;
            var endTime   = ((DateTime)_rtpEndTime.DbSelectedDate).TimeOfDay;

            var days = _rcbDays.CheckedItems.Aggregate(String.Empty, (current, item) => current + (item.Value + ",")).TrimEnd(',');

            var isVald = GetIsValdAddDates(days, endDate, startDate, startTime, endTime);

            if (isVald == false)
            {
                return;
            }

            //Check for any overlap here
            var appointMentToAdd = new AppointmentTemporaryObj
            {
                AllDay    = false,
                Days      = days,
                EndDate   = (DateTime?)endDate,
                EndTime   = endTime,
                RoomId    = RoomId,
                StartDate = startDate,
                StartTime = startTime
            };

            var db = new UrbanDataContext();
            var currentAvilList = db.Manager.RoomAvailability.GetByRoomID(RoomId).OrderByDescending(t => t.StartDate).ToList();

            //Check if date to add is valid over existing range of dates.
            if (AppointmentTemporaryObj.DoesDateOverLap(appointMentToAdd, currentAvilList.ToAppointmentTempObject()))
            {
                WriteFeedBackMaster(FeedbackType.Error, "Date overlaps");
                return;
            }
            var newAppointment = new RoomAvailability
            {
                AllDay    = appointMentToAdd.AllDay,
                Days      = appointMentToAdd.Days == String.Empty ? null : appointMentToAdd.Days,
                EndDate   = appointMentToAdd.EndDate,
                EndTime   = appointMentToAdd.EndTime,
                RoomID    = RoomId,
                StartDate = appointMentToAdd.StartDate,
                StartTime = appointMentToAdd.StartTime
            };

            db.RoomAvailability.InsertOnSubmit(newAppointment);
            db.SubmitChanges();
            RebindGridAndScheduler();
        }