public void CheckForConflictsTest() { Setup(); Meeting meeting1 = _meetingService.Add(new Meeting() { Title = "Meeting 1", Description = "This is a meeting.", StartTime = new DateTime(2021, 4, 1, 13, 30, 0), EndTime = new DateTime(2021, 4, 1, 14, 30, 0), Owner = user1 }); Meeting meeting2 = _meetingService.Add(new Meeting() { Title = "Meeting 2", Description = "This is a meeting.", StartTime = new DateTime(2021, 4, 1, 13, 0, 0), EndTime = new DateTime(2021, 4, 1, 14, 0, 0), Owner = user1 }); List <Meeting> meetings = _meetingService.CheckForConflicts(new List <Meeting>() { meeting1, meeting2 }); Assert.Contains(meetings[1].Id, meetings[0].ConflictingIds); Assert.Contains(meetings[0].Id, meetings[1].ConflictingIds); Cleanup(); }
public IHttpActionResult Post([FromBody] MeetingViewModelApi MVMA) { if (!ModelState.IsValid) { return(BadRequest("Invalid data.")); } Meeting M = new Meeting(); M.IdMeet = MVMA.IdMeet; M.text = MVMA.text; M.start_date = MVMA.start_date; M.end_date = MVMA.end_date; MS.Add(M); MS.Commit(); return(Ok(M)); }
public ActionResult Create(MeetingViewModel mvm) { if (!Request.IsAuthenticated) { return(RedirectToAction("Login", "Account")); } var currentUserId = User.Identity.GetUserId(); int myInt = int.Parse(currentUserId); User u = us.GetById(myInt); Meeting m = new Meeting(); m.IdMeet = mvm.IdMeet; m.text = mvm.text; m.start_date = mvm.start_date; m.end_date = mvm.end_date; ms.Add(m); ms.Commit(); return(RedirectToAction("Index")); }
public IActionResult Post(AddMeetingModel model) { if (ModelState.IsValid) { if (!_roomService.GetRooms(model.StartTime, model.EndTime).Any(r => r.Id == model.RoomId)) { return(BadRequest("Room unavailable.")); } var meeting = _meetingService.Add(new Meeting() { Title = model.Title, Description = model.Description, StartTime = model.StartTime, EndTime = model.EndTime, Owner = _userService.GetCurrentUser(HttpContext), Participants = model.ParticipantIds.Select(pid => _userService.GetById(pid)).ToList(), Room = _roomService.GetRoomById(model.RoomId) }); return(Created(Url.Action(nameof(Get), new { meeting.Id }), _meetingService.CheckForConflicts(meeting))); } return(BadRequest()); }
public ContentResult Save(int?id, FormCollection actionValues) { var action = new DataAction(actionValues); var changedEvent = DHXEventsHelper.Bind <Meeting>(actionValues); var entities = new MeetingService(); try { switch (action.Type) { case DataActionTypes.Insert: entities.Add(changedEvent); break; case DataActionTypes.Delete: changedEvent = entities.GetAll().FirstOrDefault(ev => ev.IdMeet == action.SourceId); entities.Delete(changedEvent); break; default: // "update" var target = entities.GetAll().Single(e => e.IdMeet == changedEvent.IdMeet); DHXEventsHelper.Update(target, changedEvent, new List <string> { "id" }); break; } entities.Commit(); action.TargetId = changedEvent.IdMeet; } catch (Exception a) { action.Type = DataActionTypes.Error; } return(new AjaxSaveResponse(action)); }