public IActionResult Put(uint id, EditMeetingModel model)
        {
            if (ModelState.IsValid)
            {
                if (!_roomService.GetRooms(model.StartTime, model.EndTime, model.Id).Any(r => r.Id == model.RoomId))
                {
                    return(BadRequest(new { message = "Room unavailable." }));
                }

                var meeting = _meetingService.GetMeetingById(id);
                if (meeting is null)
                {
                    return(NotFound());
                }
                if (meeting.Owner != _userService.GetCurrentUser(HttpContext))
                {
                    return(Unauthorized());
                }

                meeting.Title        = model.Title;
                meeting.Description  = model.Description;
                meeting.StartTime    = model.StartTime;
                meeting.EndTime      = model.EndTime;
                meeting.Participants = model.ParticipantIds.Select(pid => _userService.GetById(pid)).ToList();
                meeting.Room         = _roomService.GetRoomById(model.RoomId);
                return(Ok(_meetingService.CheckForConflicts(_meetingService.Update(meeting))));
            }
            return(BadRequest());
        }
Exemple #2
0
        public ActionResult Edit_organizor(int meetingID)
        {
            MeetingPlaceService           meetingPlaceService = new MeetingPlaceService();
            List <MeetingPlaceForMeeting> meetingPlaces       = null;

            meetingPlaceService.getAllForMeeting(out meetingPlaces);

            MeetingInfo    meeting        = null;
            MeetingService meetingService = new MeetingService();

            meetingService.getOne(meetingID, out meeting);

            EditMeetingModel model = new EditMeetingModel
            {
                meeting       = meeting,
                meetingPlaces = meetingPlaces
            };

            Session["meetingID"] = meetingID;

            return(View(model));
        }