コード例 #1
0
        /// <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);
        }
コード例 #2
0
 /// <summary>
 ///     Handles the Click event of the _btnDeny 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 _btnDeny_Click(object sender, EventArgs e)
 {
     if (RoomPosterMode == (int)PosterModeEnum.RoomPoster)
     {
         var db       = new UrbanDataContext();
         var reserver = db.Manager.RoomReservation.GetByKey(RoomReservationId);
         var user     = db.Manager.User.GetByKey(reserver.ReserverUserID);
         reserver.Approved = true;
         db.SubmitChanges();
         //Set status to approved and email and redirect.
         RoomReservationEmailUtilities.RoomReservationDenied(reserver.Room, user, RoomReservationId, _rContent.Content);
         RadAjaxManager.GetCurrent(Page).Redirect(String.Format("MyAccount.aspx?message={0}&messageType={1}", "Room Request Denied, Email Sent", FeedbackType.Success));
     }
     else
     {
         RedirectDefaultInvalid();
     }
 }
コード例 #3
0
        /// <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");
        }