예제 #1
0
        public ActionResult <CreateBookService> Post(CreateBookRequest request)
        {
            CreateBookService  _service = new CreateBookService(_unitOfWork);
            CreateBookResponse response = _service.CreateBook(request);

            return(Ok(response));
        }
예제 #2
0
        public ActionResult Create(BookSinglePageViewModel model)
        {
            CreateBookRequest  request  = model.BookViewModel.ConvertToCreateBookRequest();
            CreateBookResponse response = _bookService.CreateBook(request);

            if (response.Success)
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                model.Success = false;
                model.Message = response.Message;
                return(View(model));
            }
        }
예제 #3
0
        public CreateBookResponse CreateBook(CreateBookRequest request)
        {
            CreateBookResponse response = new CreateBookResponse();

            try
            {
                Book book = request.ConvertToBook();
                _bookRepository.Create(book);
                response.Success = true;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Message = ex.Message;
            }
            return(response);
        }
예제 #4
0
        public IHttpActionResult AddNewBook(CreateBookRequest request)
        {
            var response = new CreateBookResponse();
            var dtoInput = AutoMapper.Mapper.Map <CreateNewBookInput>(request);

            try
            {
                _bookBLL.AddNewBook(dtoInput);
            }
            catch (Exception ex)
            {
                response.Messages = ex.Message;
                response.Success  = false;
            }

            return(Ok(response));
        }
        public CreateBookResponse CreateBook(CreateBookRequest request)
        {
            var response = new CreateBookResponse();
            var entity   = CommonLogic.SetMapping <CreateBookRequest, Book>(request);

            try
            {
                //----------------------using EF-----------------
                _context.Add(entity);
                _context.SaveChanges();
                response.IsSuccess = true;
            }
            catch
            {
                throw new Exception();
            }
            return(response);
        }