Example #1
0
        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));
        }
Example #2
0
        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));
        }
Example #3
0
 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());
     }
 }
Example #4
0
 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());
 }
Example #5
0
        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));
        }
Example #6
0
 public async Task <IActionResult> Index()
 {
     return(View(Mapper.Map <IEnumerable <CustomerDTO> >(await CustomerGetService.GetAsync())));
 }
Example #7
0
 public async Task <CustomerDTO> Get(int id)
 {
     return(Mapper.Map <CustomerDTO>(await CustomerGetService.GetAsync(new CustomerIndentityModel(id))));
 }
Example #8
0
 public async Task <IEnumerable <CustomerDTO> > GetAll()
 {
     return(Mapper.Map <IEnumerable <CustomerDTO> >(await CustomerGetService.GetAsync()));
 }