Exemplo n.º 1
0
        public static bool AddIdentifyingCode(IdentifyingCodeInfo code)
        {
            if (code != null)
            {
                var addResult = false;
                code.IdentifyingCode = Utils.Number(12);

                using (var context = new WXDBContext())
                {
                    addResult = new IdentifyingCodeRepository(context).AddIdentifyingCode(code);
                }

                // 如果IdentifyingCode在数据库中存在,则递归执行此方法重新获取编号
                if (!addResult)
                {
                    AddIdentifyingCode(code);
                }
                else
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 2
0
 public void SearchIdentifyingCodeDetailForSearch_IdentifyingCode_ReturnDTO()
 {
     var db  = new WXDBContext();
     var obj = new IdentifyingCodeInfo()
     {
         ModuleName = "restaurant", IdentifyingCodeId = Guid.Parse("15EB49FB-B41D-4101-B882-29DDF746F0B0")
     };
     var result = new IdentifyingCodeRepository(db).GetIdentifyingCodeDetailById(obj);
 }
Exemplo n.º 3
0
        public static bool ModifyIdentifyingCodeInfo(IdentifyingCodeInfo code)
        {
            if (code == null)
            {
                return(false);
            }

            using (var context = new WXDBContext())
            {
                return(new IdentifyingCodeRepository(context).Update(code));
            }
        }
Exemplo n.º 4
0
        public static IList <IdentifyingCodeDetailSearchDTO> GetIdentifyingCodeDetailById(string identifyingCodeId, string moduleName)
        {
            if (string.IsNullOrEmpty(identifyingCodeId))
            {
                return(null);
            }

            var obj = new IdentifyingCodeInfo()
            {
                IdentifyingCodeId = Guid.Parse(identifyingCodeId), ModuleName = moduleName
            };

            return(new IdentifyingCodeRepository(new WXDBContext()).GetIdentifyingCodeDetailById(obj));
        }
Exemplo n.º 5
0
        public static IList <OrderDetailDTO> GetOrderDetail(int shopId, string moduleName, string condition)
        {
            if (string.IsNullOrEmpty(moduleName))
            {
                return(null);
            }

            var obj = new IdentifyingCodeInfo()
            {
                ShopId = shopId.ToString(), ModuleName = moduleName
            };

            return(new IdentifyingCodeRepository(new WXDBContext()).GetOrderDetail(obj, condition));
        }
Exemplo n.º 6
0
        private bool CreateOrderProcess()
        {
            var hotel     = new BLL.wx_hotels_info().GetModel(Convert.ToInt32(MyCommFun.QueryString("hotelid")));
            var isSuccess = false;

            if (hotel == null)
            {
                return(false);
            }

            using (var scope = new TransactionScope())
            {
                var order = this.CreateOrder();

                if (order != null)
                {
                    for (var i = 0; i < order.orderNum; i++)
                    {
                        var iCode = new IdentifyingCodeInfo()
                        {
                            IdentifyingCodeId = Guid.NewGuid(),
                            CreateTime        = DateTime.Now,
                            IdentifyingCode   = string.Empty,
                            ModifyTime        = DateTime.Now,
                            ModuleName        = "hotel",
                            OrderCode         = order.OrderNumber,
                            OrderId           = order.id.ToString(),
                            ProductCode       = order.roomType,
                            ProductId         = order.roomid.ToString(),
                            ShopId            = order.hotelid.Value.ToString(),
                            Wid    = hotel.wid.Value,
                            Status = 0
                        };
                        IdentifyingCodeService.AddIdentifyingCode(iCode);
                    }

                    SendMsg(order, hotel);

                    scope.Complete();
                    isSuccess = true;
                }
            }

            return(isSuccess);
        }
        public static IList <IdentifyingCodeDetailSearchDTO> GetIdentifyingCodeDetailById(Guid identifyingCodeId, string moduleName)
        {
            if (Guid.Empty.Equals(identifyingCodeId) || string.IsNullOrEmpty(moduleName))
            {
                return(null);
            }

            var identifyingCode = new IdentifyingCodeInfo()
            {
                IdentifyingCodeId = identifyingCodeId, ModuleName = moduleName
            };

            using (var context = new HotelDbContext())
            {
                IIdentifyingCodeRepository repository = new IdentifyingCodeRepository(context); //改造方向:依赖注入,彻底去除对Infrastructure层的依赖

                return(repository.GetIdentifyingCodeDetailById(identifyingCode));
            }
        }
Exemplo n.º 8
0
        public void InsertIdentifyCode_Verification_ReturnTure()
        {
            var icode = new IdentifyingCodeInfo()
            {
                IdentifyingCodeId = Guid.NewGuid(),
                CreateTime        = DateTime.Now,
                IdentifyingCode   = "1256978741253",
                ModifyTime        = DateTime.Now,
                ModuleName        = "HotelTest",
                OrderCode         = "H201510221656123456789",
                OrderId           = "22222",
                ProductCode       = "大床房",
                ProductId         = "大床房",
                Status            = 0,
                ShopId            = "12",
                Wid = 12
            };

            var service = IdentifyingCodeService.AddIdentifyingCode(icode);

            //Assert.IsTrue(result);
        }
Exemplo n.º 9
0
 private void CreateIdentifyingCode(int wid, HotelOrderInfo order)
 {
     for (var i = 0; i < order.orderNum; i++)
     {
         var iCode = new IdentifyingCodeInfo()
         {
             IdentifyingCodeId = Guid.NewGuid(),
             CreateTime        = DateTime.Now,
             IdentifyingCode   = string.Empty,
             ModifyTime        = DateTime.Now,
             ModuleName        = "hotel",
             OrderCode         = order.orderNumber,
             OrderId           = order.id.ToString(),
             ProductCode       = order.roomType,
             ProductId         = order.roomid.ToString(),
             ShopId            = order.hotelid.ToString(),
             Wid    = wid,
             Status = 0
         };
         IdentifyingCodeService.AddIdentifyingCode(iCode);
     }
 }
Exemplo n.º 10
0
        /// <summary>
        /// The save order.
        /// </summary>
        /// <returns>
        /// The <see cref="ProcessResult"/>.
        /// </returns>
        private ProcessResult SaveOrder()
        {
            var bll = new BLL.wx_diancai_dingdan_caiping();

            Model.wx_diancai_dingdan_manage order = null;

            try
            {
                using (var scope = new TransactionScope())
                {
                    order = this.CreateOrder();
                    if (order != null)
                    {
                        var goodsInOrder = this.CreateGoodsInOrder(order);

                        if (goodsInOrder == null)
                        {
                            return(new ProcessResult()
                            {
                                IsSuccess = false, Message = "所选择的商品有误"
                            });
                        }

                        foreach (var item in goodsInOrder)
                        {
                            bll.Add(item);

                            for (var i = 0; i < item.num; i++)
                            {
                                var iCode = new IdentifyingCodeInfo()
                                {
                                    IdentifyingCodeId = Guid.NewGuid(),
                                    CreateTime        = DateTime.Now,
                                    IdentifyingCode   = string.Empty,
                                    ModifyTime        = DateTime.Now,
                                    ModuleName        = "restaurant",
                                    OrderCode         = order.orderNumber,
                                    OrderId           = order.id.ToString(),
                                    ProductCode       = item.caiId.ToString(),
                                    ProductId         = item.caiId.ToString(),
                                    ShopId            = order.shopinfoid.ToString(),
                                    Wid    = order.wid,
                                    Status = 0
                                };
                                IdentifyingCodeService.AddIdentifyingCode(iCode);
                            }
                        }
                    }
                    else
                    {
                        return(new ProcessResult()
                        {
                            IsSuccess = false, Message = "所选择的商品有误"
                        });
                    }

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                return(new ProcessResult()
                {
                    IsSuccess = false, Message = "保存订单出错"
                });
            }

            return(new ProcessResult()
            {
                IsSuccess = true, Message = "订单提交成功!请到订单查看!", BusinessData = order
            });
        }