예제 #1
0
        public void UpdateOrder(OrderCreateModel data)
        {
            var order = orderRepo.Get(data.Id);

            if (order == null)
            {
                return;
            }

            order.SenderId    = data.SenderId ?? "";
            order.RecipientId = data.RecipientId ?? "";
            order.StoreId     = data.StoreId ?? "";
            order.Notes       = data.Note ?? "";
            order.TotalWeight = data.TotalWeight ?? 0;
            order.Status      = data.status ?? "New";
            order.Shipment    = data.Shipment ?? "";
            order.ModifyDate  = TimestampStaicClass.ConvertTotimestamp(DateTime.UtcNow);
            //TODO Customer confirm
            orderRepo.SaveChanges();


            var listOldOrdertail = orderDetailRepo.GetListByOrderId(data.Id).ToList();

            orderDetailRepo.DeleteMulti(listOldOrdertail);
            var listOrderdetail = new List <OrderDetailTbl>();

            if (data.listOrdertail != null)
            {
                foreach (var item in data.listOrdertail)
                {
                    var orderdetail = new OrderDetailTbl();
                    orderdetail.createDate        = TimestampStaicClass.ConvertTotimestamp(DateTime.UtcNow);
                    orderdetail.modifyDate        = TimestampStaicClass.ConvertTotimestamp(DateTime.UtcNow);
                    orderdetail.status            = "New";
                    orderdetail.description       = item.description;
                    orderdetail.productCategoryId = item.productCategoryId;
                    orderdetail.id          = String.IsNullOrEmpty(item.id) ? Guid.NewGuid().ToString() : item.id;
                    orderdetail.orderId     = order.Id;
                    orderdetail.price       = item.price;
                    orderdetail.productCode = item.productCode;
                    orderdetail.quality     = item.quality;
                    orderdetail.weight      = item.weight;
                    listOrderdetail.Add(orderdetail);
                }
            }

            orderDetailRepo.CreateMulti(listOrderdetail);
        }
예제 #2
0
        public void CreateOrder(OrderCreateModel data)
        {
            OrderTbl order = new OrderTbl();

            order.SenderId    = data.SenderId;
            order.RecipientId = data.RecipientId;
            order.StoreId     = data.StoreId;
            order.Notes       = data.Note;
            order.TotalWeight = data.TotalWeight ?? 0;
            order.Status      = "New";
            order.Shipment    = data.Shipment;
            order.CreateDate  = TimestampStaicClass.ConvertTotimestamp(DateTime.UtcNow);
            order.ModifyDate  = TimestampStaicClass.ConvertTotimestamp(DateTime.UtcNow);
            order.Id          = Guid.NewGuid().ToString();

            orderRepo.Create(order);

            var listOrderdetail = new List <OrderDetailTbl>();

            if (data.listOrdertail != null)
            {
                foreach (var item in data.listOrdertail)
                {
                    var orderdetail = new OrderDetailTbl();
                    orderdetail.createDate        = TimestampStaicClass.ConvertTotimestamp(DateTime.UtcNow);
                    orderdetail.modifyDate        = TimestampStaicClass.ConvertTotimestamp(DateTime.UtcNow);
                    orderdetail.status            = "New";
                    orderdetail.description       = item.description;
                    orderdetail.productCategoryId = item.productCategoryId;
                    orderdetail.id          = Guid.NewGuid().ToString();
                    orderdetail.orderId     = order.Id;
                    orderdetail.price       = item.price;
                    orderdetail.productCode = item.productCode;
                    orderdetail.quality     = item.quality;
                    orderdetail.weight      = item.weight;
                    listOrderdetail.Add(orderdetail);
                }
            }

            orderDetailRepo.CreateMulti(listOrderdetail);
        }