Пример #1
0
        public async Task <IActionResult> Create(Author author)
        {
            var createAuthor = await _author.AddAsync(author);

            if (createAuthor)
            {
                return(RedirectToAction("Index"));
            }
            return(View());
        }
Пример #2
0
        public async Task <IActionResult> AddAuthor([FromBody] Author author)
        {
            var createAuthor = await _author.AddAsync(author);

            if (createAuthor)
            {
                return(Ok("Author Created"));
            }
            else
            {
                return(BadRequest(new { message = "Unable to create Author details" }));
            }
        }
Пример #3
0
        public async Task <IActionResult> AddAuthor([FromBody] Author author)
        {
            var createAuthor = await _author.AddAsync(author);

            if (createAuthor)
            {
                Console.WriteLine("I got here but error");
                return(Ok("Author Created"));
            }
            else
            {
                Console.WriteLine("Error");
                return(BadRequest(new { message = "Unable to create Author details" }));
            }
        }
Пример #4
0
        public async Task <IActionResult> Create(Author author)
        {
            var createAuthor = await _author.AddAsync(author);

            if (createAuthor)
            {
                Alert("Author created successfully.", NotificationType.success);
                return(RedirectToAction("Index"));
            }
            else
            {
                Alert("Author not created!", NotificationType.error);
            }
            return(View());
        }
Пример #5
0
        public async Task <IActionResult> Create(Author author)
        {
            author.CreatedBy = _userManager.GetUserName(User);
            var createAuthor = await _author.AddAsync(author);

            //if (createAuthor)
            //{
            //    return RedirectToAction("Index");
            //}

            if (createAuthor)
            {
                Alert("Author created successfully.", NotificationType.success);
                return(RedirectToAction("Index"));
            }
            else
            {
                Alert("Author not created!", NotificationType.error);
            }


            return(View());
        }
Пример #6
0
        public async Task <Response <AuthorModel> > Post([FromBody] AuthorModel model)
        {
            Response <AuthorModel> authorResponseModel = new Response <AuthorModel>();

            try
            {
                Author entity = _mapper.Map <Author>(model);
                entity = await(model.Id != Guid.Empty ? _author.UpdateAsync(entity) : _author.AddAsync(entity));
                authorResponseModel.Value     = _mapper.Map <AuthorModel>(entity);
                authorResponseModel.IsSuccess = true;
            }
            catch (Exception e)
            {
                authorResponseModel.Exception = e;
                authorResponseModel.IsSuccess = false;
            }

            return(authorResponseModel);
        }