public async Task <IActionResult> Edit(int?id) { if (id is null) { return(NotFound()); } var book = Mapper.Map <BookDTO>(await BookGetService.GetAsync(new BookIdentityModel((int)id))); if (book is null) { return(NotFound()); } return(View(book)); }
public async Task <IActionResult> Index() { var list = Mapper.Map <IEnumerable <BookDTO> >(await BookGetService.GetAsync()); return(View(list)); }
public async Task <IActionResult> Create() { ViewData["BookId"] = new SelectList(Mapper.Map <IEnumerable <BookDTO> >(await BookGetService.GetAsync()), "Id", "Title"); ViewData["CustomerId"] = new SelectList(Mapper.Map <IEnumerable <CustomerDTO> >(await CustomerGetService.GetAsync()), "Id", "FullName"); return(View()); }
public async Task <IActionResult> Create(OrderCreateDTO orderCreate) { try { var order = Mapper.Map <OrderDTO>( await OrderCreateService.CreateAsync(Mapper.Map <OrderUpdateModel>(orderCreate))); return(Redirect($"/orders/{order.Id}")); } catch { ViewData["BookId"] = new SelectList(Mapper.Map <IEnumerable <BookDTO> >(await BookGetService.GetAsync()), "Id", "Title"); ViewData["CustomerId"] = new SelectList(Mapper.Map <IEnumerable <CustomerDTO> >(await CustomerGetService.GetAsync()), "Id", "FullName"); return(View()); } }
public async Task <IActionResult> Edit(int?id) { if (id == null) { return(NotFound()); } var order = Mapper.Map <OrderDTO>(await OrderGetService.GetAsync(new OrderIndentityModel((int)id))); if (order == null) { return(NotFound()); } var updateDto = new OrderUpdateDTO { Id = order.Id, Arrived = order.Arrived, CustomerId = order.Customer.Id, BookId = order.Book.Id, Date = order.Date }; ViewData["BookId"] = new SelectList(Mapper.Map <IEnumerable <BookDTO> >(await BookGetService.GetAsync()), "Id", "Title", updateDto.BookId); ViewData["CustomerId"] = new SelectList(Mapper.Map <IEnumerable <CustomerDTO> >(await CustomerGetService.GetAsync()), "Id", "FullName", updateDto.CustomerId); return(View(updateDto)); }