/// <summary>
 /// Builds the address.
 /// </summary>
 /// <param name="room">The room.</param>
 private void BuildAddress(Room room)
 {
     var sb = new StringBuilder();
     sb.Append(room.Building.PrimaryAddress + " ");
     if (room.Building.SecondaryAddress != null)
         sb.Append(room.Building.SecondaryAddress + " ");
     sb.Append(room.Building.City + " ");
     sb.Append(room.Building.Zip + " ");
     sb.Append(room.Building.State + " ");
     Address = sb.ToString();
 }
        /// <summary>
        ///     Loads the page fields.
        /// </summary>
        /// <param name = "room">The room.</param>
        private void LoadPageFields(Room room)
        {
            _txtRoomTitle.Text = room.Title;
            _txtRoomNumber.Text = room.Number;
            _txtMaxOccupancy.DbValue = room.MaxOccupancy;
            var li = _cbRoomType.FindItemByValue(room.RoomTypeID.ToString());
            if (li != null) li.Selected = true;
            _rContent.Content = room.Description;

            var bLi = _cbBuilding.FindItemByValue(room.BuildingID.ToString());
            if (bLi != null) bLi.Selected = true;
        }
        /// <summary>
        ///     Sends new user account email with activation key
        /// </summary>
        /// <param name = "room">The room.</param>
        /// <param name = "u">The u.</param>
        /// <param name = "roomReservationId">The room reservation id.</param>
        /// <param name = "comments">The comments.</param>
        /// <datetime>6/11/2011-11:42 AM</datetime>
        /// <author>
        ///     nate
        /// </author>
        public static void RoomReservationCommentsSentRoomRequestor(Room room, User u, int roomReservationId, string comments)
        {
            var keys = new List<KeyValuePair<string, string>>
                           {
                               new KeyValuePair<string, string>("{!MainTitleHtml}", "Room Reservation Comments From Requestor"),
                               new KeyValuePair<string, string>("{!Subtitle01Html}", "Comments Posted"),
                               new KeyValuePair<string, string>("{!Subtitle01TextHtml}", "Room requestor for room: " + room.Number + " in " + room.Building.Name + " has posted the following comments " + comments),
                               new KeyValuePair<string, string>("{!LinkHtml}", "http://UrbanScheduler.com?RoomReservationKey=" + roomReservationId),
                               new KeyValuePair<string, string>("{!LinkTextHtml}", "Click Here To View"),
                               new KeyValuePair<string, string>("{!FormPerson}", "UrbanScheduler System")
                           };

            EmailTemplateUtilities.EmailFromFromMaster(keys, "UrbanScheduler Room Reservation Comments Posted", u, new List<int>());
        }
        /// <summary>
        ///     Sends new user account email with activation key
        /// </summary>
        /// <param name = "room">The room.</param>
        /// <param name = "u">The u.</param>
        /// <param name = "roomReservationId">The room reservation id.</param>
        /// <param name = "comments">The comments.</param>
        /// <datetime>6/11/2011-11:42 AM</datetime>
        /// <author>
        ///     nate
        /// </author>
        public static void InitiateRoomReservationRequest(Room room, User u, int roomReservationId, string comments)
        {
            var keys = new List<KeyValuePair<string, string>>
                           {
                               new KeyValuePair<string, string>("{!MainTitleHtml}", "Room Reservation Requested"),
                               new KeyValuePair<string, string>("{!Subtitle01Html}", "Action Required"),
                               new KeyValuePair<string, string>("{!Subtitle01TextHtml}", "A user has requested reservation of room: " + room.Number + " in " + room.Building.Name + " with the following comments " + comments),
                               new KeyValuePair<string, string>("{!LinkHtml}", "http://UrbanScheduler.com?RoomReservationKey=" + roomReservationId),
                               new KeyValuePair<string, string>("{!LinkTextHtml}", "Click Here To View / Approve / or Deny"),
                               new KeyValuePair<string, string>("{!FormPerson}", "UrbanScheduler System")
                           };

            EmailTemplateUtilities.EmailFromFromMaster(keys, "UrbanScheduler Room Reservation Requested", u, new List<int>());
        }
 partial void OnRoomChanging(Room value);
        /// <summary>
        ///     Sends new user account email with activation key
        /// </summary>
        /// <param name = "room">The room.</param>
        /// <param name = "u">The u.</param>
        /// <param name = "roomReservationId">The room reservation id.</param>
        /// <param name = "comments">The comments.</param>
        /// <datetime>6/11/2011-11:42 AM</datetime>
        /// <author>
        ///     nate
        /// </author>
        public static void RoomReservationDenied(Room room, User u, int roomReservationId, string comments)
        {
            var keys = new List<KeyValuePair<string, string>>
                           {
                               new KeyValuePair<string, string>("{!MainTitleHtml}", "Room Reservation Denied"),
                               new KeyValuePair<string, string>("{!Subtitle01Html}", " "),
                               new KeyValuePair<string, string>("{!Subtitle01TextHtml}", string.Format("Room requestor has denied request for room: {0} in {1} {2}" + comments, room.Number, room.Building.Name, comments.Trim() == string.Empty ? " " : " has posted the following comments " + comments)),
                               new KeyValuePair<string, string>("{!LinkHtml}", "http://UrbanScheduler.com?RoomReservationKey=" + roomReservationId),
                               new KeyValuePair<string, string>("{!LinkTextHtml}", "Click Here To View"),
                               new KeyValuePair<string, string>("{!FormPerson}", "UrbanScheduler System")
                           };

            EmailTemplateUtilities.EmailFromFromMaster(keys, "UrbanScheduler Room Request Denied", u, new List<int>());
        }
 /// <summary>
 /// Builds the content.
 /// </summary>
 /// <param name="room">The room.</param>
 private void BuildContent(Room room)
 {
     var sb = new StringBuilder();
     var javascript = String.Format("javascript:rebindParentAndRedirect('{0}')", room.Id);
     sb.Append(String.Format("<strong>Title</strong>: <a href={0}> {1} </a> <br />", javascript, room.Building.Name));
     sb.Append(String.Format("<strong>Description</strong>: {0} <br />", Utilities.Utilities.StripHtmlTextAndTags(room.Description)));
     foreach (var image in room.RoomImageLinkList)
     {
         sb.Append(String.Format("<br /><strong>Image :</strong> <img  height='100px' src='{0}'></img>", "../../Files/" + image.FileFiles.ServerFileName));
     }
     Content += sb.ToString();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="BuildingSerialObj"/> class.
 /// </summary>
 /// <param name="room">The room.</param>
 public BuildingSerialObj(Room room)
 {
     BuildAddress(room);
     BuildContent(room);
 }
 private void OnRoomListRemove(Room entity)
 {
     SendPropertyChanging(null);
     entity.RoomType = null;
     SendPropertyChanged(null);
 }
 private void OnRoomListAdd(Room entity)
 {
     SendPropertyChanging(null);
     entity.RoomType = this;
     SendPropertyChanged(null);
 }
        /// <summary>
        ///     Loads the page fields.
        /// </summary>
        /// <param name = "room">The room.</param>
        private void LoadPageFields(Room room)
        {
            //Room Information
            _txtRoomTitle.Text = room.Title;
            _txtRoomNumber.Text = room.Number;
            _txtMaxOccupancy.DbValue = room.MaxOccupancy;
            _txtRoomType.Text = room.RoomType.Name;

            //Address Information
            _txtBuildingName.Text = room.Building.Name;
            _txtPrimaryAddress.Text = room.Building.PrimaryAddress;
            _txtSecondaryAddress.Text = room.Building.SecondaryAddress;
            _txtState.Text = room.Building.State;
            _txtCity.Text = room.Building.City;
            _txtZip.Text = room.Building.Zip;

            //Description
            _litDescription.Text = room.Description;

            if (CurrentUserUtilities.GetCuIdSafely() > 0 && room.UserID != Cu.Id)
            {
                _btnReserve.Visible = true;
                _btnReserve.Enabled = true;
            }
            else
            {
                _btnReserve.Visible = false;
                _btnReserve.Enabled = false;
            }
            _rRating.Value = RoomCommentsUtilities.GetRatingForRoomAndComments(RoomId);
            _litComments.Text = RoomCommentsUtilities.BuildCommentsForRoom(RoomId);

            var imageLinks = room.RoomImageLinkList;

            var sb2 = new StringBuilder();

            foreach (var image in imageLinks)
            {
                sb2.Append(String.Format("<a href='{0}' rel='prettyPhoto[pp_gal]' title='{1}'>", "../../files/" + image.FileFiles.ServerFileName, image.ImageDescription == null || image.ImageDescription.Trim() == String.Empty ? "" : image.ImageDescription));
                sb2.Append(String.Format("<img src='{0}' height='100' alt='{1}' />", "../../files/" + image.FileFiles.ServerFileName, image.Title == null || image.Title.Trim() == String.Empty ? "" : image.Title));
                sb2.Append("</a>");
            }

            _litPrettyPhoto.Text = sb2.ToString();
        }
        /// <summary>
        ///     Processes the room creation.
        /// </summary>
        /// <param name = "db">The db.</param>
        /// <param name = "buildingId">The building id.</param>
        /// <param name = "userId">The user id.</param>
        /// <param name = "apptList">The appt list.</param>
        /// <param name = "params">The @params.</param>
        /// <returns></returns>
        public static int ProcessRoomCreation(ref UrbanDataContext db, int buildingId, int userId, IEnumerable<AppointmentTemporaryObj> apptList, ProcessRoomCreationParams @params)
        {
            //Validate Room building combination
            if (DoesRoomExistWithNumber(ref db, buildingId, @params.Number))
            {
                return -1;
            }

            if (AppointmentTemporaryObj.ValidateListDoAnyOverlapInList(apptList))
                throw new Exception("Dates Over Lap");

            var room = new Room
                           {
                               Number = @params.Number,
                               Title = @params.Name,
                               MaxOccupancy = @params.MaxOccupancy,
                               RoomTypeID = @params.Type,
                               Description = @params.Description,
                               BuildingID = buildingId,
                               UserID = userId
                           };

            db.Room.InsertOnSubmit(room);
            db.SubmitChanges();

            foreach (var availabilityDate in apptList.Select(tempAppt => new RoomAvailability
                                                                             {
                                                                                 AllDay = false, 
                                                                                 Days = tempAppt.Days == String.Empty ? null : tempAppt.Days , 
                                                                                 EndDate = tempAppt.EndDate, 
                                                                                 EndTime = tempAppt.EndTime, 
                                                                                 RoomID = room.Id, 
                                                                                 StartDate = tempAppt.StartDate, 
                                                                                 StartTime = tempAppt.StartTime
                                                                             }))
            {
                db.RoomAvailability.InsertOnSubmit(availabilityDate);
            }


            db.SubmitChanges();
            return room.Id;
        }