예제 #1
0
        public IHttpActionResult ExchangeOrder(ExchangeOrderDto orderdto)
        {
            var res = new ResponseBase();

            try
            {
                var service = new StoreService();
                var data    = service.ExchangeOrder(orderdto);

                if (!string.IsNullOrEmpty(data.message))
                {
                    res.code = "100";
                    res.msg  = data.message;
                }

                res.resData = data.detail;

                //res.resData = null;
            }
            catch (Exception ex)
            {
                res.code = "100";
                res.msg  = ex.Message;
            }
            return(Ok(res));
        }
예제 #2
0
        public BusinessResultDto ExchangeOrder(ExchangeOrderDto orderdto)
        {
            try
            {
                using (var db = base.NewDB())
                {
                    var order = new OrderInfo
                    {
                        Consignee     = orderdto.consignee,
                        AddressDetail = orderdto.addressdetail,
                        AddressRegion = orderdto.addressregion,
                        Telephone     = orderdto.telephone,

                        UserNote        = orderdto.usernote,
                        TotalPoints     = orderdto.quantity * orderdto.points,
                        OrderCommoditys = new List <OrderCommodity> {
                            new OrderCommodity {
                                Commodity         = db.Commoditys.FirstOrDefault(t => t.CommodityUID == orderdto.commodityuid),
                                Quantity          = orderdto.quantity,
                                Points            = orderdto.points,
                                TotalPoints       = orderdto.quantity * orderdto.points,
                                CommodityAttrsStr = orderdto.GetCommodityAttrsStr()
                            }
                        },
                        //UserIntegral = db.UserIntegrals.First(t => t.IntegralID == orderdto.integralid),

                        UserIntegral = db.Users.FirstOrDefault(t => t.AuthID == orderdto.authid).UserIntegral
                    };

                    var bus = new StoreBus(db);
                    var res = bus.SaveExchangeOrder(order);

                    if (res.issave)
                    {
                        db.SaveChanges();
                    }

                    return(res);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }