Ejemplo n.º 1
0
        public async void Create_Should_Call_PutItem_With_New_DeliveryId()
        {
            var delivery = new DeliveryRecord();

            var result = await _deliveryService.Create(delivery);

            Assert.True(result.Success);
            Assert.NotNull(result.Result.DeliveryId);
            _mockRepository
            .Verify(
                x => x.PutItem(
                    It.Is <DeliveryRecord>(record => record.DeliveryId == result.Result.DeliveryId)
                    )
                );
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
0
 public IActionResult Create(Delivery delivery)
 {
     _deliveryService.Create(delivery);
     var product = _productService.GetById(delivery.ProductId);
     product.Stock -= delivery.Piece;
     _productService.Update(product);
     return View("Index", _deliveryService.GetStockList());
 }
        public async Task <IActionResult> Post([FromBody] Delivery model)
        {
            string message = await _service.Validate(model);

            if (!string.IsNullOrEmpty(message))
            {
                return(BadRequest(new { message }));
            }
            return(Ok(await _service.Create(model)));
        }
Ejemplo n.º 5
0
 private void Create(Guid id, Guid customerId, string fao)
 {
     try
     {
         _savedDelivery = _deliveryService.Create(id, customerId, fao);
     }
     catch (DomainValidationException dex)
     {
         _domainValidationException = dex;
     }
 }
Ejemplo n.º 6
0
 public async Task CreateNullExecutionContextExpectArgumentNullException()
 {
     await Assert.ThrowsAsync <ArgumentNullException>(async() =>
                                                      await _deliveryService.Create(null, new DeliveryDto()));
 }
 public ActionResult CreateDelivery(DeliveryMethods model)
 {
     deliveryService.Create(model);
     TempData["message"] = "成功新增運送方式";
     return(RedirectToRoute(new { Controller = "Admin", Action = "CreateDelivery" }));
 }
        public ActionResult <DeliveryItem> Create(DeliveryItem delivery)
        {
            _deliveryService.Create(delivery);

            return(CreatedAtRoute("GetDelivery", new { id = delivery.Id.ToString() }, delivery));
        }