public ActionResult <CreateBookService> Post(CreateBookRequest request) { CreateBookService _service = new CreateBookService(_unitOfWork); CreateBookResponse response = _service.CreateBook(request); return(Ok(response)); }
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)); } }
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); }
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); }