public async Task <IActionResult> Edit(int?id) { if (id == null) { return(NotFound()); } var customer = Mapper.Map <CustomerDTO>(await CustomerGetService.GetAsync(new CustomerIndentityModel((int)id))); if (customer == null) { return(NotFound()); } return(View(customer)); }
public async Task <IActionResult> Details(int?id) { if (id == null) { return(NotFound()); } var customer = Mapper.Map <CustomerDTO>(await CustomerGetService.GetAsync(new CustomerIndentityModel((int)id))); if (customer == null) { return(NotFound()); } ViewData["Orders"] = Mapper.Map <IEnumerable <OrderDTO> >(await OrderGetService.GetByCustomerAsync(new CustomerIndentityModel((int)id))); return(View(customer)); }
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> 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> 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)); }
public async Task <IActionResult> Index() { return(View(Mapper.Map <IEnumerable <CustomerDTO> >(await CustomerGetService.GetAsync()))); }
public async Task <CustomerDTO> Get(int id) { return(Mapper.Map <CustomerDTO>(await CustomerGetService.GetAsync(new CustomerIndentityModel(id)))); }
public async Task <IEnumerable <CustomerDTO> > GetAll() { return(Mapper.Map <IEnumerable <CustomerDTO> >(await CustomerGetService.GetAsync())); }