/// <summary>
        ///     Creates the room reservation.
        /// </summary>
        /// <param name = "userId">The user id.</param>
        /// <param name = "roomId">The room id.</param>
        /// <param name = "comments">The comments.</param>
        /// <returns></returns>
        public static int CreateRoomReservation(int userId, int roomId, string comments, List<ReserveRoomTempObject> timeList)
        {
            if (timeList.Count <= 0)
                return -1;

            var db = new UrbanDataContext();

            var reservation = new RoomReservation
                                  {
                                      Approved = null,
                                      ReserverUserID = userId,
                                      RoomID = roomId,
                                      RequestedDate = DateTime.Now
                                  };
            db.RoomReservation.InsertOnSubmit(reservation);
            db.SubmitChanges();
            //Insert Dates

            foreach (var rTime in timeList.Select(r => new RoomReservationDates
                                                           {
                                                               AllDay = false, 
                                                               EndDate = r.Date.Add(r.End),
                                                               StartDate = r.Date.Add(r.Start),
                                                               RoomReservationID = reservation.Id
                                                           }))
            {
                db.RoomReservationDates.InsertOnSubmit(rTime);
            }

            if (comments.Trim() != string.Empty)
            {
                var revComments = new RoomReservationComments
                                      {
                                          Comments = comments.Trim(),
                                          DateSent = DateTime.Now,
                                          RoomReservationID = reservation.Id,
                                          UserID = userId
                                      };
                db.RoomReservationComments.InsertOnSubmit(revComments);
            }
            db.SubmitChanges();
            var room = db.Manager.Room.GetByKey(roomId);
            var user = db.Manager.User.GetByKey(room.UserID);
            RoomReservationEmailUtilities.InitiateRoomReservationRequest(room, user, reservation.Id, comments);
            return 1;
        }
 private void OnRoomReservationCommentsListRemove(RoomReservationComments entity)
 {
     SendPropertyChanging(null);
     entity.User = null;
     SendPropertyChanged(null);
 }
 private void OnRoomReservationCommentsListAdd(RoomReservationComments entity)
 {
     SendPropertyChanging(null);
     entity.User = this;
     SendPropertyChanged(null);
 }
Beispiel #4
0
 private void OnRoomReservationCommentsListRemove(RoomReservationComments entity)
 {
     SendPropertyChanging(null);
     entity.RoomReservation = null;
     SendPropertyChanged(null);
 }
Beispiel #5
0
 private void OnRoomReservationCommentsListAdd(RoomReservationComments entity)
 {
     SendPropertyChanging(null);
     entity.RoomReservation = this;
     SendPropertyChanged(null);
 }
        /// <summary>
        ///     Handles the Click event of the _btnSubmitComments 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 _btnSubmitComments_Click(object sender, EventArgs e)
        {
            if (_rContent.Content.Trim() == String.Empty)
            {
                WriteFeedBackMaster(FeedbackType.Info, "Please enter comments to send");
                return;
            }

            //Create new Reservation Comments
            var db = new UrbanDataContext();
            var revComments = new RoomReservationComments
                                  {
                                      Comments = _rContent.Content.Trim(),
                                      DateSent = DateTime.Now,
                                      RoomReservationID = RoomReservationId,
                                      UserID = Cu.Id
                                  };
            db.RoomReservationComments.InsertOnSubmit(revComments);
            db.SubmitChanges();

            var roomReservation = db.Manager.RoomReservation.GetByKey(RoomReservationId);
            var user = db.Manager.User.GetByKey(Cu.Id);

            //Emails based on who is the poster
            switch (RoomPosterMode)
            {
                case (int) PosterModeEnum.RoomPoster:
                    RoomReservationEmailUtilities.RoomReservationCommentsSentRoomPoster(roomReservation.Room, user, roomReservation.Id, _rContent.Content);
                    break;
                case (int) PosterModeEnum.RoomRequestor:
                    RoomReservationEmailUtilities.RoomReservationCommentsSentRoomRequestor(roomReservation.Room, user, roomReservation.Id, _rContent.Content);
                    break;
            }
            _rContent.Content = String.Empty;
            WriteFeedBackMaster(FeedbackType.Success, "Comments sent");
        }