public async Task <OptionModel> Insert(OptionCreateModel model) { var entity = _mapper.Map <Option>(model); await _context.Options.AddAsync(entity); await SaveAsync(); return(_mapper.Map <OptionModel>(entity)); }
public async Task <IActionResult> Post([FromBody] OptionCreateModel model) { if (ModelState.IsValid) { var option = await _service.Insert(model); return(option != null ? (IActionResult)CreatedAtRoute(nameof(GetById), option, option.Id) : Conflict()); } return(BadRequest()); }
public async Task <IActionResult> PostOption([FromBody] OptionCreateModel model) { if (ModelState.IsValid) { var item = await _service.Insert(model); if (item != null) { return(CreatedAtRoute(nameof(Get), item, item.Id)); } return(Conflict()); } return(BadRequest()); }
public async Task <IActionResult> Post([FromBody] OptionCreateModel model) { if (ModelState.IsValid) { var option = await _service.Insert(model); if (option != null) { return(Created($"/api/Options/{option.Id}", option.Id)); } return(Conflict()); } return(BadRequest()); }
public async Task InsertNewOption() { // Arrange var option = new OptionCreateModel { Text = "VisualStudio 2019" }; // Act var result = await _service.Insert(option); // Assert result.Should().NotBeNull(); result.Should().BeAssignableTo <OptionBaseModel>(); result.Id.Should().NotBe(0); }
public async Task Insert() { //Arrange var option = new OptionCreateModel { Text = "Some Order", Order = 1, QuestionId = 1 }; //Act var result = await _service.Insert(option); //Assert result.Should().NotBeNull(); result.Should().BeAssignableTo <OptionBaseModel>(); result.Should().NotBe(0); }