public ActionResult Index(MainIndexViewModel model) { try { if (model.Number.Length < 6 || model.Number.Length > 30) { throw new Exception("Введіть номер від 6 до 30 символів."); } var invoiceDto = invoicesService.SearchByNumber(model.Number); if (invoiceDto == null) { throw new Exception("Відправлення не знайдено."); } return(View("Details", mapper.Map <InvoiceViewModel>(invoiceDto))); } catch (Exception ex) { deliveryMessage.Title = "Index"; deliveryMessage.Body = ex.Message; return(View("DeliveryMessage", deliveryMessage)); } }