public JsonResult CreateOneToOne(OneToOneViewModel model) { //remove Id from modelstate if tehre. ModelState.Remove("Id"); ModelState.Remove("CreatedById"); ModelState.Remove("CreatedBy"); if (ModelState.IsValid) { using (var orgSession = OrgStore.OpenSession()) { var target = orgSession.Load<User>(model.InviteeId); var invitee = Invitee.FromUser(target); var invitees = new List<Invitee> {invitee}; var meeting = new Meeting { CreatedBy = OrgUser.ToSimpleUser(), AssignedUsers = new List<SimpleUser> { OrgUser.ToSimpleUser() }, DueDate = model.EventDate, ConsolidatedCompletionDate = model.EventDate, DurationMinutes = model.DurationMinutes, Title = model.Title, Description = model.Description, Invitees = invitees, Id = IlluminateDatabase.GenerateId<Meeting>() }; orgSession.Store(meeting); meeting.UpdateAssignees(orgSession); var notification = meeting.ToNotification(); orgSession.Store(notification); orgSession.SaveChanges(); return JsonSuccess(meeting.ToTimelineItems(), "One To One created"); } } return JsonError("Invalid data"); }
public void CreateOneToOne() { //ARRANGE var controller = GetAuthenticatedControllerMock<MeetingController>(Orguser); //MockRepository.GeneratePartialMock<AccountController>(); //set controller context. controller.ControllerContext = new ControllerContext(GetContext(true), new RouteData(), controller); var vm = new OneToOneViewModel { EventDate = DateTime.Now, Description = "Test", DurationMinutes = 60, InviteeId = Orguser.Id, Title = "Test meeting" }; //ACT var result = controller.CreateOneToOne(vm); //ASSERT var jsonresponse = ValidateAndUnwrapJsonResult(result); var unwrappedresponse = (List<TimelineItem>)jsonresponse.Data; }