public void Can_Add_Valid_Author() { // Arrange var author = new Author { AccountName = "jfang2", IsActivated = true }; // Act var newAuthor = _authorManager.Create(author); // Assert Assert.True(_authorManager.ProcessResult.Success); Assert.NotNull(newAuthor); Assert.True(newAuthor.Id != Guid.Empty, "newAuthor.Id is not empty"); }
public ActionResult Create(FormCollection collection) { try { var authorCreate = new AuthorDTO() { Name = collection["Name"], Surname = collection["Surname"] }; authorService.Create(authorCreate); return(RedirectToAction("Index")); } catch { return(View()); } }
public async Task <IActionResult> Create([FromBody] Authors inputModel) { try { if (string.IsNullOrEmpty(inputModel.Name)) { throw new Exception($"Tên tác giả {MessageConst.NOT_EMPTY_INPUT}"); } inputModel.CreatedDate = DateTime.Now; await _authorManager.Create(inputModel); return(Ok()); } catch (Exception ex) { return(StatusCode(500, ex.Message)); } }
public async Task Create(CreateAuthorInput input) { Author output = ObjectMapper.Map <Author>(input); await _authorManager.Create(output); }
public async Task Create(CreateAuthorInput input) { var author = _objectMapper.Map <Author>(input); await _authorManager.Create(author); }