Пример #1
0
        public ActionResult Create(DeliveryCreateViewModel viewmodel)
        {
            var customerId  = _jobItemService.GetById(viewmodel.JobItemId).Job.Customer.Id;
            var transaction = NHibernateSession.Current.BeginTransaction();

            try
            {
                if (viewmodel.IsIndividual)
                {
                    var delivery = _deliveryService.Create(viewmodel.Id, customerId, viewmodel.Fao);
                    _deliveryItemService.Create(Guid.NewGuid(), delivery.Id, viewmodel.JobItemId, viewmodel.Notes);
                }
                else
                {
                    _deliveryItemService.CreatePending(viewmodel.Id, viewmodel.JobItemId, customerId, viewmodel.Notes);
                }
                transaction.Commit();
                return(RedirectToAction("Details", "JobItem", new { Id = viewmodel.JobItemId }));
            }
            catch (DomainValidationException dex)
            {
                if (transaction.IsActive)
                {
                    transaction.Rollback();
                }
                ModelState.UpdateFromDomain(dex.Result);
            }
            finally
            {
                transaction.Dispose();
            }
            return(PartialView("_Details", viewmodel));
        }
Пример #2
0
 private void CreateDeliveryItem(Guid id, Guid deliveryId, Guid jobItemId, string notes)
 {
     try
     {
         _savedDeliveryItem = _deliveryItemService.Create(id, deliveryId, jobItemId, notes);
     }
     catch (DomainValidationException dex)
     {
         _domainValidationException = dex;
     }
 }