public void GetOrder_EmptyString_ShouldReturnEmptyString()
        {
            //arrange
            var input = string.Empty;

            //act
            var result = YourOrder.GetOrder(input);

            //assert
            result.Should().Be(input);
        }
        public void GetOrder_SimpleTest1_ShouldReturnCorrectValue()
        {
            //arrange
            var input = "4of Fo1r pe6ople g3ood th5e the2";

            //act
            var result = YourOrder.GetOrder(input);

            //assert
            result.Should().Be("Fo1r the2 g3ood 4of th5e pe6ople");
        }
        public void GetOrder_SimpleTest_ShouldReturnCorrectValue()
        {
            //arrange
            var input = "is2 Thi1s T4est 3a";

            //act
            var result = YourOrder.GetOrder(input);

            //assert
            result.Should().Be("Thi1s is2 3a T4est");
        }
 public void SampleTest()
 {
     Assert.AreEqual("Thi1s is2 3a T4est", YourOrder.Order("is2 Thi1s T4est 3a"));
     Assert.AreEqual("Fo1r the2 g3ood 4of th5e pe6ople", YourOrder.Order("4of Fo1r pe6ople g3ood th5e the2"));
     Assert.AreEqual("", YourOrder.Order(""));
 }
Exemple #5
0
        public C1OrderResult Show()
        {
            //
            var log = new MongoHistoryAPI()
            {
                APIUrl     = "/api/c1order/show",
                CreateTime = DateTime.Now,
                Sucess     = 1
            };

            var result = new C1OrderResult()
            {
                id  = "1",
                msg = "success"
            };

            try
            {
                var requestContent = Request.Content.ReadAsStringAsync().Result;
                var jsonserializer = new JavaScriptSerializer();
                var paser          = jsonserializer.Deserialize <C1OrderRequest>(requestContent);
                log.Content = new JavaScriptSerializer().Serialize(paser);

                if (!mongoHelper.checkLoginSession(paser.user, paser.token))
                {
                    throw new Exception("Wrong token and user login!");
                }

                //
                var c1Info = db.C1Info.Where(p => p.CInfoCommon.UserLogin == paser.user).FirstOrDefault();

                if (c1Info == null)
                {
                    throw new Exception("Sai thong tin");
                }


                int pageSize   = 20;
                int pageNumber = (paser.page ?? 1);

                var data = db.HaiOrders.Where(p => p.OrderStatus == paser.status && p.C1Id == c1Info.Id && p.CInfoCommon.CCode.Contains(paser.c2Code)).OrderByDescending(p => p.CreateDate).ToPagedList(pageNumber, pageSize).ToList();

                List <YourOrder> orders = new List <YourOrder>();

                foreach (var order in data)
                {
                    YourOrder yourOrder = new YourOrder()
                    {
                        address     = order.ReceiveAddress,
                        c2Code      = order.CInfoCommon.CCode,
                        c2Name      = order.CInfoCommon.CName,
                        code        = order.Code,
                        date        = order.CreateDate.Value.ToString("dd/MM/yyyy"),
                        dateSuggest = order.ExpectDate == null ? "" : order.ExpectDate.Value.ToString("dd/MM/yyyy"),
                        orderId     = order.Id,
                        phone       = order.ReceivePhone1
                    };

                    yourOrder.productCount = order.OrderProducts.Count();

                    orders.Add(yourOrder);
                }

                result.orders = orders;
            }
            catch (Exception e)
            {
                result.id  = "0";
                result.msg = e.Message;
                log.Sucess = 0;
            }

            log.ReturnInfo = new JavaScriptSerializer().Serialize(result);

            mongoHelper.createHistoryAPI(log);

            return(result);
        }
Exemple #6
0
        public YourOrderResult Show()
        {
            //
            var log = new MongoHistoryAPI()
            {
                APIUrl     = "/api/stafforder/show",
                CreateTime = DateTime.Now,
                Sucess     = 1
            };

            var result = new YourOrderResult()
            {
                id     = "1",
                msg    = "success",
                orders = new List <YourOrder>()
            };

            try
            {
                var requestContent = Request.Content.ReadAsStringAsync().Result;
                var jsonserializer = new JavaScriptSerializer();
                var paser          = jsonserializer.Deserialize <StaffOrderRequest>(requestContent);
                log.Content = new JavaScriptSerializer().Serialize(paser);

                if (!mongoHelper.checkLoginSession(paser.user, paser.token))
                {
                    throw new Exception("Wrong token and user login!");
                }

                //
                var staff = db.HaiStaffs.Where(p => p.UserLogin == paser.user).FirstOrDefault();

                if (staff == null)
                {
                    throw new Exception("Sai thong tin");
                }


                int pageSize   = 50;
                int pageNumber = (paser.page ?? 1);

                if (String.IsNullOrEmpty(paser.fdate) || String.IsNullOrEmpty(paser.tdate))
                {
                    paser.tdate = DateTime.Now.ToString("d/M/yyyy");
                    paser.fdate = DateTime.Now.ToString("d/M/yyyy");
                }


                if (String.IsNullOrEmpty(paser.place))
                {
                    paser.place = "";
                }

                if (String.IsNullOrEmpty(paser.status))
                {
                    paser.status = "";
                }

                if (String.IsNullOrEmpty(paser.c1Code))
                {
                    paser.c1Code = "";
                }

                if (String.IsNullOrEmpty(paser.processId))
                {
                    paser.processId = "";
                }


                //data = staff.OrderStaffs.Where(p => p.HaiOrder.CInfoCommon.CCode.Contains(paser.c2Code) && p.ProcessId == "create").Select(p => p.HaiOrder).OrderByDescending(p => p.CreateDate).ToPagedList(pageNumber, pageSize).ToList();
                DateTime fromDate = DateTime.ParseExact(paser.fdate, "d/M/yyyy", null);

                DateTime toDate = DateTime.ParseExact(paser.tdate, "d/M/yyyy", null);

                var data = (from p in db.OrderStaffs
                            where DbFunctions.TruncateTime(p.CreateTime)
                            >= DbFunctions.TruncateTime(fromDate) && DbFunctions.TruncateTime(p.CreateTime)
                            <= DbFunctions.TruncateTime(toDate) && p.StaffId == staff.Id && p.HaiOrder.C1Code.Contains(paser.c1Code) &&
                            p.HaiOrder.SalePlace.Contains(paser.place) && p.HaiOrder.DStatus.Contains(paser.status) && p.HaiOrder.OrderStatus.Contains(paser.processId)
                            select p.HaiOrder).OrderByDescending(p => p.CreateDate).ToPagedList(pageNumber, pageSize);

                //   var data = db.get_list_orders(fromDate.ToString("yyyy-MM-dd"), toDate.ToString("yyyy-MM-dd"), "%" + paser.processId + "%", "%" + paser.status + "%", "%" + staff.Code + "%", "%" + pa + "%").ToList();
                // List<YourOrder> orders = new List<YourOrder>();

                foreach (var order in data)
                {
                    YourOrder yourOrder = new YourOrder()
                    {
                        address            = order.ReceiveAddress,
                        c2Code             = order.CInfoCommon.CCode,
                        c2Name             = order.CInfoCommon.CName,
                        code               = order.Code,
                        date               = order.CreateDate.Value.ToString("dd/MM/yyyy"),
                        dateSuggest        = order.ExpectDate == null ? "" : order.ExpectDate.Value.ToString("dd/MM/yyyy"),
                        orderId            = order.Id,
                        phone              = order.ReceivePhone1,
                        status             = order.OrderStt.Name,
                        money              = order.PriceTotal == null?0:order.PriceTotal,
                        statusCode         = order.OrderStt.Id,
                        deliveryStatus     = order.DeliveryStatu.Name,
                        deliveryStatusCode = order.DeliveryStatu.Id,
                        shipInfo           = order.SType.Name
                    };

                    if (order.OrderType == "checkinorder")
                    {
                        yourOrder.inCheckin = 1;
                    }
                    else
                    {
                        yourOrder.inCheckin = 0;
                    }

                    if (order.PayType == "debt")
                    {
                        yourOrder.payInfo = order.PType.Name + " - " + order.DebtTimeLine + " ngày";
                    }
                    else
                    {
                        yourOrder.payInfo = order.PType.Name;
                    }

                    if (order.SalePlace == "B")
                    {
                        yourOrder.senderCode = order.BrachCode;
                        yourOrder.senderName = "Tại chi nhánh";
                    }
                    else
                    {
                        yourOrder.senderName = order.C1Name;
                        yourOrder.senderCode = order.C1Code;
                    }

                    yourOrder.productCount = order.OrderProducts.Count();
                    result.orders.Add(yourOrder);
                }
                //  result.orders = orders;
            }
            catch (Exception e)
            {
                result.id  = "0";
                result.msg = e.Message;
                log.Sucess = 0;
            }

            log.ReturnInfo = new JavaScriptSerializer().Serialize(result);

            mongoHelper.createHistoryAPI(log);

            return(result);
        }