public ActionResult HouseScoreView(long id)
        {
            OrderInfoView orderInfo = null;

            orderInfo = OperateContext.Current.BLLSession.IOrderInfoViewBLL.GetListBy(m => m.ID == id).FirstOrDefault();
            return(View(orderInfo));
        }
示例#2
0
        public IActionResult AddOrder([FromBody] OrderInfoView orderInfoView)
        {
            var userId = CurrentUser.Id;

            if (string.IsNullOrEmpty(orderInfoView.ClientName))
            {
                return(JsonError("客户信息未填写"));
            }
            orderInfoView.ClientName = orderInfoView.ClientName.Trim();
            if (orderInfoView.ClientId == null)
            {
                var clientModel = _clientInfoRepository.FindBy(e => e.UserId == userId && e.ClientName == orderInfoView.ClientName && e.IsDel == 0);

                if (clientModel.Any())
                {
                    return(JsonError("该客户信息已存在,请直接选择"));
                }
                else
                {
                    ClientInfo clientInfo = new ClientInfo()
                    {
                        ClientName = orderInfoView.ClientName,
                        UserId     = userId,
                        IsDel      = 0,
                        CreateTime = DateTime.Now,
                        UpdateTime = DateTime.Now
                    };

                    var clientId = _clientInfoRepository.Add(clientInfo);
                    orderInfoView.ClientId = clientId;
                }
            }

            try
            {
                orderInfoView.UserId = userId;
                _orderInfoRepository.AddOrder(orderInfoView);
                return(JsonOk(""));
            }
            catch (Exception e)
            {
                return(JsonError(e.Message));
            }
        }
示例#3
0
        /// <summary>
        /// 添加订单
        /// </summary>
        /// <param name="orderInfoView"></param>
        /// <returns></returns>
        public bool AddOrder(OrderInfoView orderInfoView)
        {
            using (var transaction = _context.Database.BeginTransaction())
            {
                try
                {
                    var orderInfo = new OrderInfo()
                    {
                        ClientId   = orderInfoView.ClientId ?? 0,
                        CreateTime = DateTime.Now,
                        UserId     = orderInfoView.UserId,
                        IsDel      = 0,
                        IsPrint    = 0
                    };

                    var entityEntry = _context.Set <OrderInfo>().Add(orderInfo);
                    _context.SaveChanges();

                    foreach (var item in orderInfoView.OrderGoodsList)
                    {
                        item.OrderId = entityEntry.Entity.Id;

                        _context.Set <OrderGoods>().Add(item);
                    }
                    _context.SaveChanges();

                    transaction.Commit();
                    return(true);
                }
                catch (Exception)
                {
                    transaction.Rollback();
                    return(false);
                }
            }
        }