Example #1
0
        public async Task <IActionResult> Post([FromBody] SprintCreateViewModel sprint)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var sprintId = _sprintService.CreateSprint(sprint);

            return(CreatedAtAction("Get", new { id = sprintId }, sprintId));
        }
        public ActionResult Create(SprintCreateViewModel model)
        {
            if (this.ModelState.IsValid)
            {
                Sprint sprint = model.ToEntity();
                this.Storage.GetRepository <ISprintRepository>().Create(sprint, this.GetCurrentUserName());
                this.Storage.Save();

                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
Example #3
0
        public async Task PostMethod_ValidInput_ReturnsCorrectResponse(int projectId, string sprintName)
        {
            var project = new SprintCreateViewModel {
                ProjectId = projectId, Name = sprintName
            };
            var result = await _controller.Object.Post(project);

            _sprintService.Verify(x =>
                                  x.CreateSprint(
                                      It.Is <SprintCreateViewModel>(
                                          p => p.ProjectId == projectId && p.Name == sprintName)
                                      ));

            Assert.AreEqual(typeof(CreatedAtActionResult), result.GetType());
        }
Example #4
0
        public IActionResult Post(SprintCreateViewModel model)
        {
            if (this.ModelState.IsValid)
            {
                Sprint sprint = model.ToEntity();
                var    repo   = this.Storage.GetRepository <ISprintRepository>();

                repo.Create(sprint, GetCurrentUserName());
                this.Storage.Save();

                return(Ok(new { success = true }));
            }

            return(BadRequest(new { success = false }));
        }
Example #5
0
        public int CreateSprint(SprintCreateViewModel sprint)
        {
            var sprintToBeCreated = new Database.Entities.Sprint
            {
                ProjectId = sprint.ProjectId,
                Name      = sprint.Name,
                StartDate = null,
                EndDate   = null
            };

            _dbContext.Sprints.Add(sprintToBeCreated);
            _dbContext.SaveChanges();

            return(sprintToBeCreated.SprintId);
        }
        public ActionResult Create()
        {
            var model = new SprintCreateViewModel();

            return(View(model));
        }