Exemple #1
0
        public async Task Should_Create_Activity()
        {
            const string name = "Hello World";

            // Act
            var createActivityTemplateOutput = await _activityAppService.CreateActivity(new CreateActivityInput
            {
                Name       = name,
                LocationId = null,
                TagTexts   = new[] { "Happy", "Hello" },
                StartTime  = new DateTime(2017, 3, 12, 2, 10, 0),
                EndTime    = new DateTime(2017, 3, 12, 3, 10, 0)
            });

            // Assert
            createActivityTemplateOutput.ShouldNotBe(null);
            createActivityTemplateOutput.Id.ShouldBeOfType <Guid>();

            // Act
            var id = createActivityTemplateOutput.Id;
            var getActivityOutput = await _activityAppService.GetActivity(new EntityDto <Guid>(id));

            // Assert
            getActivityOutput.ShouldNotBe(null);
            getActivityOutput.Activity.ShouldNotBe(null);
            getActivityOutput.Activity.Id.ShouldBe(id);
            getActivityOutput.Activity.Name.ShouldBe(name);
            getActivityOutput.Activity.StartTime.ShouldBe(new DateTime(2017, 3, 12, 2, 10, 0));
            getActivityOutput.Activity.EndTime.ShouldBe(new DateTime(2017, 3, 12, 3, 10, 0));
        }
        public async Task<ActionResult> Create(CreateActivityInput input)
        {

            // TODO: Add insert logic here

            if (ModelState.IsValid)
            {
                await _activityAppService.CreateActivity(input);
                return RedirectToAction("Index");

            }
            else
            {
                ViewBag.RevenueSourceId = _revenueSourceAppService.GetRevenueResources().Select(c => new SelectListItem { Value = c.Id.ToString(), Text = c.Description });
                return View(input);
            }

        }