Пример #1
0
 public Guid AddOrdering(AddOrderingCommand command)
 {
   string orderCode = _keyGenerationReportService.GetCode(KeyTypeObjects.Order).CodeNew;
   var ordering = new Ordering()
   {
     OrderingId = Guid.NewGuid(),
     Address = command.Address,
     Phone = command.Phone,
     ExchangeRateId = command.ExchangeRateId,
     Note = command.Note,
     TotalDiscuss = command.TotalDiscuss,
     PersonId = command.PersonId,
     CreatedDate = DateTime.Now,
     Status = (int)StatusOrderingEnum.New,
     OrderingCode = orderCode,
     IsDelivered = false,
     IsDeposit = false,
     IsPaid = false,
     IsDownPayment = false,
     IsPayAtHome = false,
     NoteApproved = "",
     NoteCustomer = "",
     CreatedByName = "",
     CreatedBy = command.PersonId,
     Type = 0,
     TotalAmount = 0,
     TotalCount = 0,
     TotalCustomFees = 0,
     TotalDomesticCharges = 0,
     TotalDownPayment = 0,
     TotalQuantity = 0,
     TotalPrice = 0,
     TotalShipAbroad = 0,
     TotalShipInternal = 0,
     TotalVat = 0,
     TotalWage = 0,
     TransportFee = 0,
     WeightFee = 0
   };
   _orderingService.Insert(ordering);
   _unitOfWork.SaveChanges();
   return ordering.OrderingId;
 }
Пример #2
0
    public ActionResult AddOrder(OrderingModel model)
    {
      try
      {
        if (model.TotalDiscuss == null)
        {
          model.TotalDiscuss = 0;
        }
        if (model.Price == null)
        {
          model.Price = 0;
        }
        if (model.Quantity == null)
        {
          model.Quantity = 1;
        }
          var createCommand = new AddOrderingCommand((Guid)model.PersonId, model.ExchangeRateId, model.Phone, model.Address, model.Note, (double)model.TotalDiscuss);
          model.OrderingId = _orderingCommandService.AddOrdering(createCommand);
          _orderingDetailCommandService.AddOrderingDetail(new AddOrderingDetailCommand(model.ProductCode, model.Name, model.Brand, (decimal)model.Price, (int)model.Quantity, model.Note, model.Link, model.LinkUrl, model.Color, model.Size,model.OrderingId));
          return ModelState.JsonValidation(new { Success = true, model });

      }
      catch (Exception ex)
      {

        return ModelState.JsonValidation(new { Success = false,Error = ex.Message });
      }
     
    
    }