Exemplo n.º 1
0
        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");
        }
Exemplo n.º 2
0
 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());
     }
 }
Exemplo n.º 3
0
        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));
            }
        }
Exemplo n.º 4
0
 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);
 }