Exemple #1
0
 static public bool SaveClientAddresses(string entityID, List <EBaseAddress> addressList)
 {
     try {
         if (!addressList.Any())
         {
             return(true);
         }
         using var context = new SMySQLContext();
         foreach (EBaseAddress eAddress in addressList)
         {
             eAddress.modificationDateUTC = DateTime.UtcNow;
             eAddress.entityID            = entityID;
             if (string.IsNullOrEmpty(eAddress.id))
             {
                 eAddress.id = Guid.NewGuid().ToString();
                 eAddress.creationDateUTC = DateTime.UtcNow;
                 var e = context.BaseAddresses.Add(eAddress);
                 context.SaveChanges();
                 //return e.Entity.id;
             }
             else
             {
                 var e = context.BaseAddresses.Update(eAddress);
                 context.SaveChanges();
                 //return e.Entity.id;
             }
         }
         return(true);
     } catch (DbUpdateException e) {
         Debug.WriteLine(e.InnerException.ToString());
         return(false);
     }
 }
 static public bool ConfirmOrder(EDeliveryConfirmOrder eDeliveryConfirmOrder)
 {
     try {
         using var context = new SMySQLContext();
         EDeliveryOrder e = new EDeliveryOrder();
         e.companyID         = eDeliveryConfirmOrder.companyID;
         e.visualID          = GetNextVisualID(e.companyID);
         e.entityID          = eDeliveryConfirmOrder.userID;
         e.paymentMethodType = eDeliveryConfirmOrder.paymentMethodType;
         e.total             = eDeliveryConfirmOrder.total;
         e.creationDateUTC   = e.modificationDateUTC = DateTime.UtcNow;
         if (eDeliveryConfirmOrder.creationDateLocal == null)
         {
             e.creationDateLocal = DateTime.UtcNow;
         }
         else
         {
             e.creationDateLocal = eDeliveryConfirmOrder.creationDateLocal;
         }
         e.notes     = eDeliveryConfirmOrder.comments;
         e.status    = DeliveryStatus.PendingApproval;
         e.content   = JsonConvert.SerializeObject(eDeliveryConfirmOrder.productList);
         e.changeFor = eDeliveryConfirmOrder.changeFor;
         var result = context.DeliveryOrders.Add(e);
         context.SaveChanges();
         return(true);
     } catch (Exception e) {
         SLogger.LogError(e);
     }
     return(false);
 }