public ActionResult Create(OrderViewModel orderViewModel)
 {
     if (ModelState.IsValid)
     {
         try
         {
             orderViewModel.Tasks = orderViewModel.Tasks ?? new List<TaskViewModel>();
             var notSubmitedTask = orderViewModel.Tasks.Where(x => x.IsDelete && x.Id == 0).ToList();
             var endDate = new DateTime(orderViewModel.EndDate.Year, orderViewModel.EndDate.Month,
                 orderViewModel.EndDate.Day, orderViewModel.EndTime.Hours, orderViewModel.EndTime.Minutes, 00);
             var order = new Order()
             {
                 Title = orderViewModel.Title,
                 Id = orderViewModel.Id,
                 UpdatedDate = orderViewModel.UpdatedDate,
                 CreatedDate = orderViewModel.CreatedDate,
                 EndDate = endDate,
                 ClientId = orderViewModel.ClientId,
                 Type = orderViewModel.Type,
                 Tasks = orderViewModel.Tasks.Except(notSubmitedTask).Select(x=> new Task
                 {
                     Title = x.Title,
                     Id = x.Id,
                     Resources = x.Resources,
                     OrderId = x.OrderId
                 }).ToList()
             };
             var identity = _service.Save(order);
             return RedirectToAction("Edit", new {@id = identity});
         }
         catch (Exception exception)
         {
             throw;
         }
     }
     ViewBag.ClientList = new SelectList(_clientService.GetAll(), "Id", "Name");
     return View(orderViewModel);
 }
 public ActionResult Client(int id)
 {
     var orderList = _service.GetByClient(id);
     var viewModel = new OrderViewModel();
     return View(viewModel.GetListViewModel(orderList));
 }
 public ActionResult Index()
 {
     var orderList = _service.GetAll();
     var viewModel = new OrderViewModel();
     return View(viewModel.GetListViewModel(orderList));
 }
 public ActionResult View(int id)
 {
     var order = _service.GetById(id);
     var viewModel = new OrderViewModel(order);
     return View(viewModel);
 }
 public ActionResult Edit(int id)
 {
     var order = _service.GetById(id);
     var viewModel = new OrderViewModel(order);
     ViewBag.ClientList = new SelectList(_clientService.GetAll(), "Id", "Name");
     viewModel.EndTime = new TimeSpan(0, viewModel.EndDate.Hour, viewModel.EndDate.Minute, viewModel.EndDate.Second);
     return View("Create", viewModel);
 }