public async Task AddTest() { // ARRANGE PlannerService service = new PlannerService(ctxDb); PlannerController controller = SetupPlannerController(service).Result; Room room = new Room { Gebouw = "A", Verdiep = 1, Nummer = "01", Type = "Lokaal" }; ctxDb.Room.Add(room); Course course = new Course { Vakcode = "AAA01A", Titel = "testvak", Studiepunten = 4 }; ctxDb.Course.Add(course); ctxDb.SaveChanges(); string dat = DateTime.Today.AddDays(1).ToString("yyyy-MM-dd"); string uur = "11:00"; double duratie = 2.0; int lokaalId = ctxDb.Room.Where(r => r.Gebouw == "A" && r.Verdiep == 1 && r.Nummer == "01").FirstOrDefault().Id; int vakId = ctxDb.Course.Where(c => c.Vakcode == "AAA01A").FirstOrDefault().Id; // ACT var res = await controller.Add(dat, uur, lokaalId, duratie, vakId, null, null, 0); // ASSERT Assert.IsTrue(res is ActionResult); Assert.IsNotNull(ctxDb.CourseMoment.Where(cm => cm.CourseId == vakId && cm.RoomId == lokaalId).FirstOrDefault()); }
////public override void Cleanup() ////{ //// // Clean own resources if needed //// base.Cleanup(); ////} internal async Task InitializeAsync(Guid?id, int?index) { IsInit = true; InitNewSearch = true; SelectedSearch = null; SelectedReisMogelijkheid = null; DataLoader.LoadingState = LoadingState.None; InitNewSearch = false; if (id.HasValue) { var search = await PlannerService.GetSearchAsync(id.Value); if (search != null) { _tempIndex = index; SelectedSearch = search; } } RefreshSearchHistoryAsync(); }
private async Task <PlannerController> SetupPlannerController(PlannerService service) { ctxDb.Roles.Add(new IdentityRole { Name = "Student", NormalizedName = "STUDENT" }); ctxDb.SaveChanges(); AccountService accService = new AccountService(userManager, signInManager); var user = await accService.RegisterUser(new RegisterViewModel { RNum = "r0000001", Email = "*****@*****.**", Name = "Thomas", SurName = "Claes", Password = "******", ConfirmPassword = "******", GeboorteDatum = new DateTime(1998, 9, 21) }); IOptions <IdentityOptions> options = Options.Create <IdentityOptions>(new IdentityOptions { }); UserClaimsPrincipalFactory <ApplicationUser> userClaimFactory = new UserClaimsPrincipalFactory <ApplicationUser>(userManager, options); var claim = userClaimFactory.CreateAsync(user).Result; var httpContext = new Mock <HttpContext>(); httpContext.Setup(x => x.User).Returns(claim); var context = new ControllerContext(new ActionContext(httpContext.Object, new RouteData(), new ControllerActionDescriptor())); return(new PlannerController(service, userManager, signInManager) { ControllerContext = context, TempData = new TempDataDictionary(httpContext.Object, Mock.Of <ITempDataProvider>()) }); }
private int AddTestPlanning(PlannerService service) { ApplicationUser user = new ApplicationUser { UserName = "******", Email = "*****@*****.**", GeboorteDatum = new DateTime(1998, 09, 21), Naam = "Claes", VoorNaam = "Thomas", EmailConfirmed = true }; ctxDb.Users.Add(user); Room room = new Room { Gebouw = "A", Verdiep = 1, Nummer = "01", Type = "Lokaal", Capaciteit = 20 }; ctxDb.Room.Add(room); Course course = new Course { Vakcode = "AAA01A", Titel = "testvak", Studiepunten = 4 }; ctxDb.Course.Add(course); ctxDb.SaveChanges(); var userFull = ctxDb.Users.Where(u => u.UserName == "r0664186").FirstOrDefault(); int roomId = ctxDb.Room.Where(r => r.Type == "Lokaal").FirstOrDefault().Id; int courseId = ctxDb.Course.Where(c => c.Vakcode == "AAA01A").FirstOrDefault().Id; DateTime datum = new DateTime(DateTime.Now.Year, DateTime.Now.Month, (DateTime.Now.Day + 1)); DateTime start = new DateTime(1800, 1, 1, 11, 0, 0); double duratie = 2.0; service.AddPlanning(userFull, datum, start, duratie, roomId, courseId, null, null, 3); return(ctxDb.CourseMoment.Where(cm => cm.CourseId == courseId && cm.RoomId == roomId).FirstOrDefault().Id); }
private async Task SaveIdea(IDialogContext context, IAwaitable <GraphServiceClient> result) { var planService = new PlannerService(await result); var ideaService = new IdeaService(await result); var plan = await planService.GetTeamPlanAsync(Team); if (plan == null) { throw new ApplicationException($"Could not found plan named '{Team.DisplayName}'"); } var plannerTask = await ideaService.CreateAsync(plan.Id, idea.Title, idea.StartDate, idea.Owners.Select(i => i.Id).FirstOrDefault(), idea.Description); var plannerTaskUrl = ideaService.GetIdeaUrl(Team.Id, plan.Id, plannerTask.Id); try { var clientContext = await AuthenticationHelper.GetAppOnlySharePointClientContextAsync(); var metricsService = new MetricsService(clientContext); await metricsService.CreateMetricIdeaAsync(metric.Id, plannerTask, Constants.IdeasPlan.Buckets.NewIdea, plannerTaskUrl); } catch (Exception ex) { await context.SayAsync("Failed to add item to MetricIdea list: " + ex.Message); } await context.SayAsync("Idea created."); context.Done(idea); }
public void GetPlanningLectAdminTest() { // ARRANGE PlannerService service = new PlannerService(ctxDb); AddCm(); int courseId = ctxDb.Course.Where(c => c.Vakcode == "MGP01A").FirstOrDefault().Id; int roomId = ctxDb.Room.Where(r => r.Gebouw == "A" & r.Verdiep == 0 & r.Nummer == "01").FirstOrDefault().Id; var room = ctxDb.Room.Where(r => r.Gebouw == "A" & r.Verdiep == 0 & r.Nummer == "01").FirstOrDefault(); int scheduleId = ctxDb.Schedule.Where(s => s.Datum == new DateTime(DateTime.Now.Year, DateTime.Now.Month, (DateTime.Now.Day + 1))).FirstOrDefault().Id; var schedule = ctxDb.Schedule.Where(s => s.Datum == new DateTime(DateTime.Now.Year, DateTime.Now.Month, (DateTime.Now.Day + 1))).FirstOrDefault(); string userId = ctxDb.Users.Where(u => u.UserName == "r0664186").FirstOrDefault().Id; // ACT var plannerList = service.GetPlanningLectAdmin(GetIso8601WeekOfYear(DateTime.Now)); // ASSERT Assert.IsTrue(plannerList.Count() > 0); Assert.AreEqual(courseId, plannerList[0].cId); Assert.AreEqual(room.Gebouw, plannerList[0].Gebouw); Assert.AreEqual(room.Verdiep, plannerList[0].Verdiep); Assert.AreEqual(room.Nummer, plannerList[0].Nummer); Assert.AreEqual(schedule.Datum, plannerList[0].Datum); }
public Importacao() { _groupsService = new GroupsService(); _plannetService = new PlannerService(); _context = new ImportacaoContext(); _usersService = new UsersService(); }
private async Task ListIdeasAsync(IDialogContext context, IAwaitable <GraphServiceClient> result) { var plannerService = new PlannerService(await result); var ideaService = new IdeaService(await result); var plan = await plannerService.GetTeamPlanAsync(Team); var ideas = await ideaService.GetAsync(Team, plan.Id, status, from); var summary = ideas.Length > 0 ? $"Getting {ideas.Length} {(ideas.Length > 1 ? "ideas" : "idea")} from Microsoft Planner, Please wait..." : "No idea was found."; await context.SayAsync(summary); foreach (var bucket in Constants.IdeasPlan.Buckets.All) { var bucketIdeas = ideas.Where(i => i.Bucket == bucket).ToArray(); if (!bucketIdeas.Any()) { continue; } if (string.IsNullOrEmpty(status)) { await context.SayAsync($"{bucket} ({bucketIdeas.Length + " " + (bucket.Length > 1 ? "ideas" : "idea")})"); } int pageSize = 6; int pageCount = (bucketIdeas.Length + pageSize - 1) / pageSize; for (int page = 0; page < pageCount; page++) { var message = context.MakeMessage(); message.AttachmentLayout = AttachmentLayoutTypes.Carousel; var pageIdeas = bucketIdeas.Skip(pageSize * page).Take(pageSize).ToArray(); foreach (var idea in pageIdeas) { await ideaService.GetDetailsAsync(idea); var url = ideaService.GetIdeaUrl(Team.Id, plan.Id, idea.Id); var owners = $"Owners: {idea.Owners.Select(i => i.DisplayName).Join(", ")}"; var text = $"Start Date<br/>{idea.StartDate?.DateTime.ToShortDateString()}"; if (idea.Description.IsNotNullAndEmpty()) { text += $"<br/><br/>{idea.Description.Replace("\r\n", "<br/>").Replace("\n", "<br/>")}"; } var viewAction = new CardAction(ActionTypes.OpenUrl, "View", value: url); var heroCard = new HeroCard(idea.Title, owners, text, buttons: new List <CardAction> { viewAction }); message.Attachments.Add(heroCard.ToAttachment()); } await context.PostAsync(message); } } context.Done(ideas); }
private void DeleteHistory() { PlannerService.DeleteSearchHistoryAsync(); SearchHistory.Clear(); RaisePropertyChanged(() => SearchHistory); SelectedReisMogelijkheid = null; SelectedSearch = null; }
public void GetStudsInCmTest() { // ARRANGE PlannerService service = new PlannerService(ctxDb); int cmId = AddCm(); int courseId = ctxDb.Course.Where(c => c.Vakcode == "MGP01A").FirstOrDefault().Id; ctxDb.Users.Add(new ApplicationUser { UserName = "******", Email = "*****@*****.**", GeboorteDatum = new DateTime(1998, 09, 21), Naam = "Claes", VoorNaam = "Thomas", EmailConfirmed = true }); ctxDb.Users.Add(new ApplicationUser { UserName = "******", Email = "*****@*****.**", GeboorteDatum = new DateTime(1998, 09, 21), Naam = "Claes", VoorNaam = "Thomas", EmailConfirmed = true }); ctxDb.Users.Add(new ApplicationUser { UserName = "******", Email = "*****@*****.**", GeboorteDatum = new DateTime(1998, 09, 21), Naam = "Claes", VoorNaam = "Thomas", EmailConfirmed = true }); ctxDb.SaveChanges(); string user1Id = ctxDb.Users.Where(u => u.UserName == "r0000001").FirstOrDefault().Id; string user2Id = ctxDb.Users.Where(u => u.UserName == "r0000002").FirstOrDefault().Id; string user3Id = ctxDb.Users.Where(u => u.UserName == "r0000003").FirstOrDefault().Id; ctxDb.CourseUser.Add(new CourseUser { CourseId = courseId, ApplicationUserId = user1Id, GoedGekeurd = true, AfwijzingBeschr = null }); ctxDb.CourseUser.Add(new CourseUser { CourseId = courseId, ApplicationUserId = user2Id, GoedGekeurd = true, AfwijzingBeschr = null }); ctxDb.CourseUser.Add(new CourseUser { CourseId = courseId, ApplicationUserId = user3Id, GoedGekeurd = true, AfwijzingBeschr = null }); ctxDb.SaveChanges(); ctxDb.CourseMomentUsers.Add(new CourseMomentUsers { ApplicationUserId = user1Id, CoursMomentId = cmId }); ctxDb.CourseMomentUsers.Add(new CourseMomentUsers { ApplicationUserId = user2Id, CoursMomentId = cmId }); ctxDb.SaveChanges(); // ACT var UList = service.GetStudsInCm(cmId); // ASSERT Assert.IsTrue(UList[0].IsSelected); Assert.AreEqual(user1Id, UList[0].userId); Assert.IsTrue(UList[1].IsSelected); Assert.AreEqual(user2Id, UList[1].userId); Assert.IsFalse(UList[2].IsSelected); Assert.AreEqual(user3Id, UList[2].userId); }
public static HomeIndexViewModel ForUserPage(string username, int Page_ID) { IInfastructureService infastructure = new InfastructureService(); IPlannerService plannerService = new PlannerService(); return(new HomeIndexViewModel { navSection = infastructure.PageStructure_GetBySelected(Page_ID), events = plannerService.Event_GetByUser(username) }); }
public Result <IList <Planner> > GetByClientId(int id) { var result = new Result <IList <Planner> >(); PlannerService plannerService = new PlannerService(); var lstPlanner = plannerService.GetByClientId(id); result.Value = (IList <Planner>)lstPlanner; result.IsSuccess = true; return(result); }
private async Task DoSearch() { if (Date == DateTime.MinValue) { Date = DateTime.Now; } if (Time == DateTime.MinValue) { Time = DateTime.Now; } if (string.IsNullOrEmpty(Type)) { Type = "vertrek"; } //Create planner object with GUID PlannerSearch search = new PlannerSearch() { Id = Guid.NewGuid(), SearchDateTime = DateTime.Now, VanStation = VanStation, NaarStation = NaarStation, ViaStation = ViaStation, IsHogesnelheid = IsHogesnelheid, IsYearCard = IsYearCard, Type = Type, Date = Date, Time = Time }; if (search.VanStation != null && search.NaarStation != null) { try { //Save settings var settings = SettingService.GetSettings(); settings.HasYearCard = IsYearCard; settings.UseHsl = IsHogesnelheid; SettingService.SaveSettings(settings); } catch { //never allow it to crash, this is really important } //Save planner object await PlannerService.AddSearchAsync(search); //Navigate to new page and pass GUID //string url = string.Format("/Views/Reisadvies.xaml?id={0}", search.Id); NavigationService.NavigateToReisadvies(search.Id); } }
public Result <Planner> GetByPlannerId(int id) { var result = new Result <Planner>(); PlannerService plannerService = new PlannerService(); var planner = plannerService.GetByPlannerId(id); result.Value = planner; result.IsSuccess = true; return(result); }
public void GetTopicTest() { // ARRANGE PlannerService service = new PlannerService(ctxDb); int cmId = AddCm(); // ACT var planner = service.GetTopic(cmId, false, null); // ASSERT Assert.AreEqual(cmId, planner.cmId); }
public void EditStudsInCm_Set_Test() { // ARRANGE PlannerService service = new PlannerService(ctxDb); PlannerController controller = SetupPlannerController(service).Result; int cmId = AddTestPlanning(service); ctxDb.Users.Add(new ApplicationUser { UserName = "******", Email = "*****@*****.**", GeboorteDatum = new DateTime(1998, 09, 21), Naam = "Claes", VoorNaam = "Thomas", EmailConfirmed = true }); ctxDb.Users.Add(new ApplicationUser { UserName = "******", Email = "*****@*****.**", GeboorteDatum = new DateTime(1998, 09, 21), Naam = "Claes", VoorNaam = "Thomas", EmailConfirmed = true }); ctxDb.Users.Add(new ApplicationUser { UserName = "******", Email = "*****@*****.**", GeboorteDatum = new DateTime(1998, 09, 21), Naam = "Claes", VoorNaam = "Thomas", EmailConfirmed = true }); ctxDb.SaveChanges(); string user1Id = ctxDb.Users.Where(u => u.UserName == "r0000001").FirstOrDefault().Id; string user2Id = ctxDb.Users.Where(u => u.UserName == "r0000002").FirstOrDefault().Id; string user3Id = ctxDb.Users.Where(u => u.UserName == "r0000003").FirstOrDefault().Id; int courseId = ctxDb.Course.Where(c => c.Vakcode == "AAA01A").FirstOrDefault().Id; ctxDb.CourseUser.Add(new CourseUser { ApplicationUserId = user1Id, CourseId = courseId, GoedGekeurd = true }); ctxDb.CourseUser.Add(new CourseUser { ApplicationUserId = user2Id, CourseId = courseId, GoedGekeurd = true }); ctxDb.CourseUser.Add(new CourseUser { ApplicationUserId = user3Id, CourseId = courseId, GoedGekeurd = true }); ctxDb.SaveChanges(); List <EditStudInCmViewModel> modelList = (List <EditStudInCmViewModel>)(((ViewResult)controller.EditStudsInCm(cmId)).Model); foreach (EditStudInCmViewModel stud in modelList) { stud.IsSelected = true; } // ACT var res = controller.EditStudsInCm(modelList, cmId); // ASSERT Assert.IsTrue(res is ActionResult); Assert.IsNotNull(ctxDb.CourseMomentUsers.Where(cmu => cmu.ApplicationUserId == user1Id).FirstOrDefault()); Assert.IsNotNull(ctxDb.CourseMomentUsers.Where(cmu => cmu.ApplicationUserId == user2Id).FirstOrDefault()); Assert.IsNotNull(ctxDb.CourseMomentUsers.Where(cmu => cmu.ApplicationUserId == user3Id).FirstOrDefault()); }
private async Task DeleteSingleHistoryAsync(Guid id) { var item = SearchHistory.Where(x => x.Id == id).FirstOrDefault(); if (item != null) { SearchHistory.Remove(item); } await PlannerService.DeleteSearchAsync(id); await RefreshSearchHistoryAsync(); }
private async Task RefreshSearchHistoryAsync() { var items = await PlannerService.GetListFromStoreAsync(); SearchHistory.Clear(); foreach (var item in items) { SearchHistory.Add(item); } RaisePropertyChanged(() => SearchHistory); RaisePropertyChanged(() => SearchHistorySmall); }
public void GetCourseMomentsTest() { // ARRANGE PlannerService service = new PlannerService(ctxDb); int cmId = AddCm(); int vakcodeId = ctxDb.Course.Where(c => c.Vakcode == "MGP01A").FirstOrDefault().Id; string vakcode = ctxDb.Course.Find(vakcodeId).Vakcode; // ACT var plannerList = service.GetCourseMoments(vakcodeId); // ASSERT Assert.AreEqual(vakcode, plannerList.FirstOrDefault().Vakcode); }
public void DeleteTest() { // ARRANGE PlannerService service = new PlannerService(ctxDb); PlannerController controller = SetupPlannerController(service).Result; var cmId = AddTestPlanning(service); // ACT var res = controller.Delete(cmId); // ASSERT Assert.IsTrue(res is ActionResult); Assert.IsNull(ctxDb.CourseMoment.Where(cm => cm.Id == cmId).FirstOrDefault()); }
private async Task <DialogTurnResult> CreateIdeaPhase2Async(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var tokenResponse = (TokenResponse)stepContext.Result; if (tokenResponse?.Token == null) { await stepContext.Context.SendActivityAsync(MessageFactory.Text("Login was not successful please try again."), cancellationToken); return(await stepContext.EndDialogAsync(null, cancellationToken)); } var userProfile = await base.UserProfileAccessor.GetAsync(stepContext.Context); var team = userProfile.SelectedTeam; var createIdeaOptions = (CreateIdeaOptions)stepContext.Options; var planService = new PlannerService(tokenResponse.Token); var plan = await planService.GetTeamPlanAsync(team.Id, team.DisplayName); if (plan == null) { var message = $"Failed to create the idea: could not find plan named '{team.DisplayName}'"; await stepContext.Context.SendActivityAsync(message); } else { var description = $"Next Steps\r\n{createIdeaOptions.NextSteps}" + $"\r\n\r\nAligned to Metric\r\n{createIdeaOptions.Metric}"; var ideaService = new IdeaService(tokenResponse.Token); try { await ideaService.CreateAsync(plan.Id, createIdeaOptions.Title, new DateTimeOffset(createIdeaOptions.StartDate.Value, TimeSpan.Zero), createIdeaOptions.Owner, description ); await stepContext.Context.SendActivityAsync("Idea created."); } catch (Exception ex) { var message = $"Failed to create the idea: {ex.Message}"; await stepContext.Context.SendActivityAsync(message); } } return(await stepContext.EndDialogAsync(null, cancellationToken)); }
public void DeletePlanningTest() { // ARRANGE PlannerService service = new PlannerService(ctxDb); int cmId = AddCm(); int scheduleId = ctxDb.Schedule.Where(s => s.Datum == new DateTime(DateTime.Now.Year, DateTime.Now.Month, (DateTime.Now.Day + 1))).FirstOrDefault().Id; int roomId = ctxDb.Room.Where(r => r.Gebouw == "A" & r.Verdiep == 0 & r.Nummer == "01").FirstOrDefault().Id; // ACT service.DeletePlanning(cmId); // ASSERT Assert.IsNull(ctxDb.CourseMoment.Where(cm => cm.ScheduleId == scheduleId && cm.RoomId == roomId).FirstOrDefault()); Assert.IsTrue(!ctxDb.CourseMoment.Any()); }
////public override void Cleanup() ////{ //// // Clean own resources if needed //// base.Cleanup(); ////} internal async Task Initialize(Guid?id) { PlannerSearch = null; ReisPrijs = null; if (id.HasValue) { var search = await PlannerService.GetSearchAsync(id.Value); if (search != null) { PlannerSearch = search; ReisPrijs = await DataLoader.LoadAsync(() => NSApiService.GetPrijs(PlannerSearch)); } } }
public Result Delete(Planner planner) { var result = new Result(); try { PlannerService plannerService = new PlannerService(); plannerService.Delete(planner); result.IsSuccess = true; } catch (Exception exception) { result.IsSuccess = false; result.ExceptionInfo = exception; } return(result); }
public Result Update(FinancialPlanner.Common.Model.Planner planner) { var result = new Result(); try { PlannerService plannerService = new PlannerService(); plannerService.Update(planner); result.IsSuccess = true; } catch (Exception exception) { result.IsSuccess = false; result.ExceptionInfo = exception; } return(result); }
public async static Task RemoveObsoleteIdeas([TimerTrigger("0 0 * * * *")] TimerInfo timerInfo) { var operation = "Remove obsolete ideas"; LogService.LogOperationStarted(operation); using (var spClientContext = await AuthenticationHelper.GetSharePointClientAppOnlyContextAsync()) { var plannerService = new PlannerService(spClientContext); try { await plannerService.ReoveObsoleteIdeas(); } catch (Exception ex) { LogService.LogError(ex); } } LogService.LogOperationEnded(operation); }
public void ViewTopicTest() { // ARRANGE PlannerService service = new PlannerService(ctxDb); PlannerController controller = SetupPlannerController(service).Result; int cmId = AddTestPlanning(service); // ACT var res = controller.ViewTopic(cmId).Result; // ASSERT Assert.IsTrue(res is ActionResult); var vRes = (ViewResult)res; Assert.IsNotNull(vRes.Model); var model = (Planner)vRes.Model; Assert.AreEqual(cmId, model.cmId); }
public void EditPlanningTest() { // ARRANGE PlannerService service = new PlannerService(ctxDb); Course course1 = new Course { Vakcode = "BBB01B", Titel = "testvak", Studiepunten = 4 }; ctxDb.Course.Add(course1); Room room1 = new Room { Gebouw = "B", Verdiep = 0, Nummer = "01", Type = "Lokaal", Capaciteit = 10 }; ctxDb.Room.Add(room1); int cmId = AddCm(); string userId = ctxDb.Users.Where(u => u.UserName == "r0664186").FirstOrDefault().Id; int newCourseId = ctxDb.Course.Where(c => c.Vakcode == "BBB01B").FirstOrDefault().Id; int newRoomId = ctxDb.Room.Where(r => r.Gebouw == "B" & r.Verdiep == 0 & r.Nummer == "01").FirstOrDefault().Id; var newUser = ctxDb.Users.Find(userId); DateTime newDatum = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); string newDatumString = newDatum.ToString("yyyy-MM-dd"); string newStart = "13:00"; double newDuratie = 1.0; string newLessenlijst = "Editplanning test lesmoment"; // ACT service.EditPlanning(cmId, newCourseId, newDatumString, newStart, newDuratie, newRoomId, newLessenlijst, newUser); // ASSERT var newCm = ctxDb.CourseMoment.Find(cmId); Assert.AreEqual(newCourseId, newCm.CourseId); Assert.AreEqual(newRoomId, newCm.RoomId); Assert.AreEqual(newUser.Id, newCm.ApplicationUserId); Assert.AreEqual(ctxDb.Schedule.Where(s => s.Datum == newDatum).FirstOrDefault().Id, newCm.ScheduleId); Assert.AreEqual(newLessenlijst, newCm.LessenLijst); }
private async Task SaveIdea(IDialogContext context, IAwaitable <GraphServiceClient> result) { var planService = new PlannerService(await result); var ideaService = new IdeaService(await result); var plan = await planService.GetTeamPlanAsync(Team); if (plan == null) { throw new ApplicationException($"Could not found plan named '{Team.DisplayName}'"); } var plannerTask = await ideaService.CreateAsync(plan.Id, idea.Title, idea.StartDate, idea.Owners.Select(i => i.Id).FirstOrDefault(), idea.Description); var plannerTaskUrl = ideaService.GetIdeaUrl(Team.Id, plan.Id, plannerTask.Id); try { var clientContext = await AuthenticationHelper.GetAppOnlySharePointClientContextAsync(); var metricsService = new MetricsService(clientContext); await metricsService.CreateMetricIdeaAsync(metric.Id, plannerTask, Constants.IdeasPlan.Buckets.NewIdea, plannerTaskUrl); } catch (Exception ex) { await context.SayAsync("Failed to add item to MetricIdea list: " + ex.Message); } await context.SayAsync("Idea created."); //var viewAction = new CardAction(ActionTypes.OpenUrl, "View", value: plannerTaskUrl); //var heroCard = new HeroCard( // text: "Idea created.", // buttons: new List<CardAction> { viewAction }); //var message = context.MakeMessage(); //message.Attachments.Add(heroCard.ToAttachment()); //await context.PostAsync(message); context.Done(idea); }
public void IndexTest() { // ARRANGE PlannerService service = new PlannerService(ctxDb); PlannerController controller = SetupPlannerController(service).Result; AddTestPlanning(service); // ACT var res = controller.Index(0).Result; // ASSERT Assert.IsTrue(res is ActionResult); var vRes = (ViewResult)res; Assert.IsNotNull(vRes.Model); var model = (List <Planner>)vRes.Model; Assert.IsTrue(model.Any()); Assert.IsNotNull(model.Where(p => p.Vakcode == "AAA01A" && p.Gebouw == "A" && p.Verdiep == 1 && p.Nummer == "01").FirstOrDefault()); }