Ejemplo n.º 1
0
        public async Task <IActionResult> AddNewEvent(GroupWithEventsViewModel model)
        {
            var eventsIds = model.Events.Where(x => x.IsAssigned).Select(x => x.Id).ToList();

            if (eventsIds.Count() == 0)
            {
                model.Error = true;
                return(this.View(model));
            }

            await this.service.AssignEventsToGroupAsync(model.Id, eventsIds);

            return(this.RedirectToAction("GroupDetails", new { id = model.Id }));
        }
Ejemplo n.º 2
0
        public async Task GetGroupModelAsyncShouldReturnCorrectModel()
        {
            var firstgroupId = await this.CreateGroupAsync(null, "First Group");

            await this.CreateGroupAsync();

            var model = new GroupWithEventsViewModel()
            {
                Id    = firstgroupId,
                Name  = "First Group",
                Error = false,
            };

            var resultModel = await this.Service.GetGroupModelAsync <GroupWithEventsViewModel>(firstgroupId);

            Assert.Equal(model.Id, resultModel.Id);
            Assert.Equal(model.Name, resultModel.Name);
            Assert.False(resultModel.Error);
            Assert.Empty(resultModel.Events);
        }