Ejemplo n.º 1
0
 public void Initialize()
 {
     try
     {
         Customer customer = _CustomerManager.GetAll().FirstOrDefault();
         if (customer.InCustomerId > 0)
         {
             for (int i = 0; i < 5; i++)
             {
                 var result = _OrderManager.Add(new Order {
                     StProductName = "Masa " + i, FlQuantity = 1, InCustomerId = customer.InCustomerId, InStatus = (int)StatusInfo.Active, StDescription = "TEST"
                 });
                 if (!result.Succeeded)
                 {
                     break;
                 }
             }
             var list = _OrderManager.GetAll();
             Assert.NotEmpty(list);
         }
         else
         {
             System.Console.WriteLine("Lütfen Önce bir Müşteri Ekleyiniz.");
             Assert.NotEmpty(null);
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Ejemplo n.º 2
0
 //create order db
 public void createOrder(object obj)
 {
     try
     {
         Order             order = null;
         UserAuthorization aut   = null;
         while (true)
         {
             order = orderQueue.Receive();
             if (order != null)
             {
                 aut = orderQueue.ReceiveUserAuth();
                 if (aut != null)
                 {
                     Console.WriteLine("生成订单消息:用户ID为" + order.UserID);
                     Console.WriteLine("生成订单履历");
                     Console.WriteLine("增加车状态履历");
                     orderDB.Create(order);
                     orderDB.Add(aut);
                     //增加一条CarStat
                     zscManager.updateCarStat(order);
                 }
             }
             Thread.Sleep(100);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("createOrder消息DB异常" + ex.ToString());
     }
 }
Ejemplo n.º 3
0
        public string Buy(Order purch)
        {
            _managerorder.Add(purch);


            return("Спасибо," + purch.Date + ", за покупку ");
        }
        public async Task <IActionResult> RequestOrder(OrderRequest orderRequest)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            UserAgent userAgent = await GetAgentAndUser(orderRequest.UserName, orderRequest.AgentName);

            Order order = new Order
            {
                AgentId   = userAgent.Agent.Id,
                UserId    = userAgent.User.Id,
                Location  = userAgent.User.UserAddress.Address,
                AgentRate = userAgent.Agent.Rate,
                Date      = DateTime.UtcNow
            };

            orderDbContext.Add(order);

            orderDbContext.Complete();

            messageContext.Clients.All.SendAsync("Send", "New request has been established");

            return(Ok());
        }
Ejemplo n.º 5
0
        public IActionResult Add([FromBody] OrderDTO orderDto)
        {
            try
            {
                var claimRole       = _httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.Role);
                var claimEmployeeId = _httpContextAccessor.HttpContext.User.FindFirst("EmployeeId");
                orderDto.EmployeeId = (claimEmployeeId == null) ? 0 : Int32.Parse(claimEmployeeId.Value);

                var roleValue = (claimRole != null) ? claimRole.Value : "";

                return(Ok(_orderManager.Add(orderDto, roleValue)));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Post([FromBody] AddUpdateOderApiModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            return(Ok(await manager.Add(model)));
        }
        public IActionResult AddOrder(Order item)
        {
            var result = _orderManager.Add(item);

            if (result.Success)
            {
                return(Ok(result.Success));
            }
            return(BadRequest(result.Message));
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> Buy(Order purch)
        {
            ClaimsPrincipal currentUser = this.User;

            purch.ClientId = currentUser.FindFirst(ClaimTypes.NameIdentifier).Value;


            _managerorder.Add(purch);
            _managertour.IncRating(purch.TourId);



            //return $"thanks, {User.Identity.Name}";
            return(RedirectToAction("BuyResult", "Catalog", new { OrderId = purch.Id }));
        }
Ejemplo n.º 9
0
 public ActionResult NewOrder(ServicePageViewModel model)
 {
     try
     {
         var service = _servicesManager.GetById(model.Id);
         model.Price = service.price;
         var entity = Mapper.Map <ServicePageViewModel, Order>(model);
         _orderManager.Add(entity);
         return(RedirectToRoute("UserPage"));
     }
     catch (Exception)
     {
         return(RedirectToRoute("ServicePage", new { id = model.Id }));
     }
 }
Ejemplo n.º 10
0
        public bool OrderAuthorization(string UserId, string OrderId, string Telphone, out string msg)
        {
            //1.判断当前用户能否给别人授权
            User user = UserDb_manager.queryBeAutho(Telphone);

            if (user == null)
            {
                msg = "被授权用户没有通过审核,授权失败";
                return(false);
            }
            if (UserId.Equals(user.UserId))
            {
                msg = "被授权用户不能是自己,授权失败";
                return(false);
            }
            //根据用户id查询当前是否存在有效订单
            if (db_manager.queryValidOrderById(user.UserId))
            {
                msg = "被授权用户已经存在有效订单,授权失败";
                return(false);
            }
            if (!db_manager.queryValidOrderById(UserId))
            {
                msg = "授权用户当前不存在有效订单,授权失败";
                return(false);
            }
            //是否已经授权过
            if (!db_manager.AuthorizeOrNot(OrderId))
            {
                msg = "授权用户已经授权,授权失败";
                return(false);
            }
            //----------可以执行授权-----------
            UserAuthorization userAuth = new UserAuthorization();

            userAuth.Id      = Guid.NewGuid().ToString().Replace("-", "");
            userAuth.Date    = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            userAuth.OrderId = OrderId;
            //此处是被授权用户Id
            userAuth.UserId = user.UserId;
            userAuth.Status = (int)Commons.Authorized.AUTHORIZE;
            //2.增加授权履历
            db_manager.Add(userAuth);
            msg = "用户授权成功";
            return(true);
        }
Ejemplo n.º 11
0
        public IActionResult Create(OrderViewModel model)
        {
            var order = _mapper.Map <Order>(model);

            bool isAdded = _orderManager.Add(order);

            if (isAdded)
            {
                return(RedirectToAction("Index"));
            }

            var products = _productManager.GetAll().Select(c => new SelectListItem()
            {
                Value = c.Id.ToString(),
                Text  = c.Name
            }).ToList();

            model.ProductSelectItems = products;

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 12
0
 public ActionResult Create(Order order)
 {
     try
     {
         if (ModelState.IsValid)
         {
             //Customer customer=_customerManager.GetById(order.CustomerId);
             //order.OrderName = customer.Name+"-"+order.OrderName + "-" + order.OrderDate.ToShortDateString();
             order.CreatedOn = DateTime.Now;
             _ordeManager.Add(order);
             _ordeManager.Save();
             this.save();
             return(RedirectToAction("Index"));
         }
         ViewBag.CustomerId = new SelectList(_customerManager.GetCustomerDropDown(), "Id", "Name", order.CustomerId);
         return(View(order));
     }
     catch (Exception ex)
     {
         this.error(ex.Message.ToString());
         return(RedirectToAction("Index"));
     }
 }
Ejemplo n.º 13
0
        public IActionResult Create([Bind("Id,CustomerId,OrderNo,OrderDate,Products,Customer,Status,ShippingAddress,PaymentMethod,ProductList,Phone")] OrderCreateViewModel model)
        {
            //var cart = Ecommerce.Abstractions.Helper.SessionHelper.GetObjectFromJson<List<Item>>(HttpContext.Session, "cart");
            //if(model.ProductList == null)
            //{
            //    model.ProductList = cart;

            //}
            if (model.OrderNo == null || model.CustomerId == 0 || model.OrderDate == null)
            {
                model.OrderDate  = DateTime.Now;
                model.CustomerId = 10004;
                model.OrderNo    = DateTime.Now.ToString() + model.CustomerId;
            }
            // model.OrderNo =
            if (ModelState.IsValid)
            {
                var order = _mapper.Map <Order>(model);
                if (_orderManager.OrderExists(model.Id))
                {
                    ViewBag.ErrorMessage = "Order Exists Already";
                }
                else
                {
                    order.Status = "Pending";

                    bool isAdded = _orderManager.Add(order);
                    long id      = order.Id;

                    if (isAdded)
                    {
                        ProductOrder po   = new ProductOrder();
                        Order        o    = _orderManager.GetById(id);
                        var          cart = CRUDOperation.WebApp.Helper.SessionHelper.GetObjectFromJson <List <Item> >(HttpContext.Session, "cart");

                        foreach (var item in cart)
                        {
                            po.ProductId = item.Product.Id;
                            long pid = item.Product.Id;
                            po.Quantity = item.Quantity;
                            int qty = item.Quantity;
                            po.OrderId    = id;
                            po.Customer   = o.Customer;
                            po.CustomerId = o.CustomerId;
                            po.Status     = "Pending";
                            _productOrderManager.Add(po);
                            //var stock = _stockManager.check(pid);
                            //stock.Quantity = stock.Quantity - qty;
                            //_stockManager.Update(stock);
                        }
                        cart.Clear();
                        CRUDOperation.WebApp.Helper.SessionHelper.SetObjectAsJson(HttpContext.Session, "cart", cart);
                        ViewBag.SuccessMessage = "Order Saved Successfully!";
                        //return nameof()
                    }
                }
            }
            else
            {
                ViewBag.ErrorMessage = "Operation Failed!";
            }

            model.OrderList = _orderManager.GetAll().ToList();
            return(View(model));
        }
Ejemplo n.º 14
0
 public string AddOrder(OrderDTO order)
 {
     return(orderManager.Add(order));
 }
Ejemplo n.º 15
0
 public IActionResult Create(GlobalModel orderToCreate)
 {
     _orderManager.Add(orderToCreate);
     return(RedirectToAction("Index"));
 }