コード例 #1
0
        public CustomerProfileModel CustomerProfile(int CustId)
        {
            using (var db = new EntityContext())
            {
                TbCustomer          customer            = customerUtility.GetCustomerById(db, CustId);
                CustomerSingleModel customerModelSource = customerUtility.CustomerSingleModelProperty(customer);
                List <TbItems>      items = db.TbItems
                                            .Include(i => i.Customer)
                                            .Include(i => i.Status)
                                            .Where(i => i.Customer.Id == CustId).ToList();
                List <ItemSingleModel> itemsModelSource = new List <ItemSingleModel>();
                if (items != null)
                {
                    itemsModelSource = itemsUtility.AssingItemsProperty(items);
                }
                ;

                CustomerProfileModel profile = new CustomerProfileModel
                {
                    customerModel = customerModelSource,
                    itemsModel    = itemsModelSource
                };
                return(profile);
            }
        }
コード例 #2
0
ファイル: ItemService.cs プロジェクト: PayBoot/AnusithExpress
        private TbItems CreateItemMethod(ItemSingleModel model, EntityContext db, DbContextTransaction dbtransact, int itemstatus)
        {
            TbItems item = new TbItems
            {
                ItemName         = model.ItemName,
                ItemValue_Baht   = model.ItemValue_Baht,
                ItemValue_Dollar = model.ItemValue_Dollar,
                ItemValue_Kip    = model.ItemValue_Kip,
                isDeleted        = false,
                Status           = db.tbItemStatuses.FirstOrDefault(s => s.Id == itemstatus),
                Customer         = customerUtility.GetCustomerById(db, model.CustomerId),
                CreatedDate      = DateTime.Now,
                ReceipverPhone   = model.ReceipverPhone,
                ReceiverAddress  = model.ReceiverAddress,
                ReceiverName     = model.ReceiverName,
                Descripttion     = model.Description
            };

            db.TbItems.Add(item);
            db.SaveChanges();
            db.Entry(item).State = EntityState.Modified;
            string        customerId = model.CustomerId.ToString().PadLeft(4, '0');
            string        itemId     = item.Id.ToString().PadLeft(7, '0');
            StringBuilder sb         = new StringBuilder();

            sb.Append("U" + customerId);
            sb.Append("I" + itemId);
            item.TrackingNumber = sb.ToString();
            db.SaveChanges();
            dbtransact.Commit();
            return(item);
        }