public void TestGoodService_GetAll_ShouldReturnAllGoods() { // Arrange var goodResult = new List <GoodViewModel> { new GoodViewModel { Id = 1, Name = "Bread Borodinskiy", Amount = 80, BarCode = 54329876 }, new GoodViewModel { Id = 4, Name = "Ice-cream Gosha 80 gr", Amount = 120, BarCode = 99990000 }, new GoodViewModel { Id = 5, Name = "Cigarettes Monte Carlo", Amount = 30, BarCode = 92926741 }, new GoodViewModel { Id = 8, Name = "Chocolate Alpen Gold", Amount = 120, BarCode = 33445522 } }; GoodService ps = new GoodService(new FakeContext()); // Act var result = ps.GetAll(); // Assert Assert.AreEqual(true, (goodResult[0].Id == result[0].Id) && (goodResult[1].Name == result[1].Name) && (goodResult[2].Amount == result[2].Amount) && (goodResult[3].BarCode == result[3].BarCode)); }
/** * 0:进行中 * 1:已经揭晓 */ public static int getStatus(int good_id) { List <Order> orders = new List <Order>(); string sql = "select * from cloudorder where goodid = @good_id"; MySqlConnection con = new MySqlConnection(Config_MySql.sqlUrl); con.Open(); MySqlCommand comm = new MySqlCommand(sql, con); comm.Parameters.Add(new MySqlParameter("@good_id", good_id)); MySqlDataReader sdr = comm.ExecuteReader(); while (sdr.Read()) { Order order = new Order(); order.Id = sdr.GetInt32("id"); order.Addtime = sdr.GetString("addtime"); order.UserId = sdr.GetInt32("userid"); order.OrderSum = 0; order.CloudCode = sdr.GetString("cloudcode"); order.GoodId = sdr.GetInt32("goodid"); order.good = GoodService.GetGoodMsg(order.GoodId); orders.Add(order); } sdr.Close(); con.Close(); if (orders.Count > 0 && orders.Count >= orders[0].good.Joinpeoplenum) { return(1); } else { return(0); } }
public static List <Order> GetOrdersByUserId(int user_id) { List <Order> orders = new List <Order>(); string sql = "select * from cloudorder where userid = @userid"; MySqlConnection con = new MySqlConnection(Config_MySql.sqlUrl); con.Open(); MySqlCommand comm = new MySqlCommand(sql, con); comm.Parameters.Add(new MySqlParameter("@userid", user_id)); MySqlDataReader sdr = comm.ExecuteReader(); while (sdr.Read()) { Order order = new Order(); order.Id = sdr.GetInt32("id"); order.Addtime = sdr.GetString("addtime"); order.UserId = sdr.GetInt32("userid"); order.OrderSum = 0; order.CloudCode = sdr.GetString("cloudcode"); order.GoodId = sdr.GetInt32("goodid"); order.good = GoodService.GetGoodMsg(order.GoodId); orders.Add(order); } sdr.Close(); con.Close(); return(orders); }
public static ShopCar getShopCarByShopCarId(int shopcarid) { ShopCar shopcar = new ShopCar(); string sql = "select * from shopcar where id=?shopcarid"; MySqlConnection con = new MySqlConnection(Config_MySql.sqlUrl); con.Open(); MySqlCommand comm = new MySqlCommand(sql, con); comm.Parameters.Add(new MySqlParameter("?shopcarid", shopcarid)); MySqlDataReader rdr = comm.ExecuteReader(); while (rdr.Read()) { shopcar.UserId = rdr.GetInt32("userid"); shopcar.GoodId = rdr.GetInt32("goodid"); shopcar.BuyTime = rdr.GetInt32("buytime"); shopcar.good = GoodService.GetGoodMsg(shopcar.GoodId); } comm.Clone(); con.Close(); return(shopcar); }
public static Order GetJinxingOrderByOrderId(int orderid) { string sql = "select * from cloudorder where id=?id"; MySqlConnection con = new MySqlConnection(Config_MySql.sqlUrl); con.Open(); MySqlCommand comm = new MySqlCommand(sql, con); comm.Parameters.Add(new MySqlParameter("?id", orderid)); MySqlDataReader rdr = comm.ExecuteReader(); Order order = new Order(); while (rdr.Read()) { order.Id = rdr.GetInt32("id"); order.UserId = rdr.GetInt32("userid"); order.CloudCode = rdr.GetString("cloudcode"); order.Addtime = rdr.GetString("addtime"); order.OrderId = rdr.GetString("orderid"); order.GoodId = rdr.GetInt32("goodid"); order.good = GoodService.GetJinxingGoodMsg(order.GoodId); } comm.Clone(); con.Close(); return(order); }
public ActionResult GetGoodData(string jsonData) { var entity = JsonHelper.DeserializeObject <Bis_Gift>(jsonData); var resultData = new GoodService().GetGoodData(entity); return(Content(JsonHelper.SerializeObject(resultData))); }
public Good getGoodId() { int id = int.Parse(Request.QueryString["id"].ToString()); good = GoodService.GetGoodMsg(id); return(good); }
public AdminController() { categoryService = new CategoryService(); goodService = new GoodService(); blobService = new BlobService(); queueService = new QueueService(); }
protected void addOrder(object sender, EventArgs e) { string buytime = buytime1.Value; int userid = 0; username = (string)Session["username"]; if (UserService.getUserIdByPhone(username) == 0) { userid = UserService.getUserIdByEmail(username); } else { userid = UserService.getUserIdByPhone(username); } int buytime_judge = int.Parse(buytime); if (buytime_judge > shopcar.good.RemainPeople || buytime_judge <= 0) { Response.Write("<script>alert('您的输入有误,请您重新输入购买个数!');location.href='Index.aspx';</script>"); } else { int buytimeInt = Convert.ToInt32(buytime); int goodid = shopcar.GoodId; string addtime = DateTime.Now.ToShortDateString().ToString(); Good value_good = GoodService.GetGoodMsg(goodid); int totalPeople = value_good.Joinpeoplenum; int old_remainpeople = value_good.RemainPeople; //生成订单编号 string orderId_head = "2017"; string orderId = orderId_head + userid + goodid; int[] codeArray = Hashtable_code(totalPeople); for (int i = 0; i < buytimeInt; i++) { int joinpeople = OrderService.GetOrderMsg(goodid); //真正云购码 string realCode = getCloudCode(codeArray, joinpeople).ToString() + userid + goodid; Order order = OrderService.AddOrder(userid, goodid, realCode, addtime, orderId); } int new_joinpeople = OrderService.GetOrderMsg(goodid); int remainpeople = totalPeople - new_joinpeople; GoodService.UpdateGoodPeople(new_joinpeople, remainpeople, goodid); if (remainpeople == 0) { //开奖 //1.依据goodid从cloudorder中随机查询一个luckycode string luckyCode = OrderService.getLuckyCodeByGoodId(goodid); //2.修改该good的信息 GoodService.UpateGoodLuckyMsg(goodid, luckyCode); //3.进入显示该商品信息的界面 Response.Write("<script>location.href='PersonalPage/PurchaseRecord/AnnouncedPurchase.aspx';</script>"); } Response.Write("<script>alert('订单添加成功!');location.href='PersonalPage/PurchaseRecord/JinxingPurchase.aspx';</script>"); } }
public List <Good> getSearch() { string searchText = Request.QueryString["content"].ToString(); List <Good> searchGoods = new List <Good>(); searchGoods = GoodService.getSearchGoods(searchText); return(searchGoods); }
protected void Page_Load(object sender, EventArgs e) { if (Session["username"] == null) { Response.Write("<script>alert('亲爱的,请先登录!');location.href='../../Login.aspx';</script>"); } int userid = getUserId(); goods = GoodService.GetUserProcessingGood(userid); }
public MainViewModel(GoodService goodService, CategoryService categoryService, ManufacturerService manufacturerService) { this.goodService = goodService; this.categoryService = categoryService; this.manufacturerService = manufacturerService; Categories = new ObservableCollection <CategoryDTO>(categoryService.GetAll()); Goods = new ObservableCollection <GoodDTO>(goodService.GetAll()); Manufacturers = new ObservableCollection <ManufacturerDTO>(manufacturerService.GetAll()); InitCommands(); }
public override bool OnStart() { // Set the maximum number of concurrent connections ServicePointManager.DefaultConnectionLimit = 12; queueService = new QueueService(); queueService.Initialize(); goodService = new GoodService(); goodService.Initialize(); return(base.OnStart()); }
private void AddOrder_Click(object sender, RoutedEventArgs e) { GoodDTO good = new GoodDTO { Height = Int32.Parse(HeightTextBox.Text), Weight = Int32.Parse(WeightTextBox.Text), Width = Int32.Parse(WidthTextBox.Text), Name = NameTextBox.Text }; GoodService goodService = new GoodService(); goodService.Create(good); MessageBox.Show("Order added"); }
//The Method Getresult will return (Response.Write) which contains search results seprated by character "~" // For E.G. "Ra~Rab~Racd~Raef~Raghi" which will going to display in search suggest box private void GetresultGood() { IGoodService service = new GoodService(); IEnumerable <goods> names = service.GetMany(c => c.label.StartsWith(clientName)); StringBuilder sb = new StringBuilder(); foreach (goods swap in names) { sb.Append(swap.label + "~"); //Create Con System.Diagnostics.Debug.WriteLine("------------------------------------///////////98 : " + swap.label); } Response.Write(sb); }
public void TestGoodService_GetGood_ShouldReturnGood() { // Arrange var goodResult = new GoodViewModel { Id = 1, Name = "Bread Borodinskiy", Amount = 80, BarCode = 54329876 }; GoodService ps = new GoodService(new FakeContext()); // Act var result = ps.GetGood(1); // Assert Assert.AreEqual(true, (goodResult.Id == result.Id) && (goodResult.Amount == result.Amount) && (goodResult.Name == result.Name) && (goodResult.BarCode == result.BarCode)); }
//Меню для таблиці Good static void GoodMenu(int Id, int idUser) { GoodService goodService = new GoodService(); while (true) { goodService.Get(Id); Console.WriteLine("Please enter good's number and you will see responses anout it or press '0'" + " if you want to return category"); int num = CheckNumber(); int goodId = goodService.GetGood(num); if (goodId == 0) { break; } else { ResponseMenu(goodId, idUser, goodId); } } }
public void addGoods() { string goodsName = goodsname.Value; string goodsValue = goodsvalue.Value; string realGoodValue; bool flag = true; foreach (char demical in goodsValue) { if (demical == '.') { flag = true; } else { flag = false; } } if (flag) { string[] sArray = goodsValue.Split('.'); realGoodValue = sArray[0]; } else { realGoodValue = goodsValue; } int joinpeoplenum = Convert.ToInt32(realGoodValue) + 10; string addtime = DateTime.Now.ToShortDateString().ToString(); string status = "进行中"; string imgUrl = imgLoad(); Good good = GoodService.addGood(goodsName, goodsValue, getUserId(), joinpeoplenum, addtime, status, imgUrl); //Response.Write("<script>alert('图片上传成功!')</script>"); Response.Write("<script>alert('商品添加成功!');location.href='ProcessingGoods.aspx';</script>"); }
/// <summary> /// /// </summary> public ValuesController() { _operatorGoodService = new GoodService(); }
protected void Page_Load(object sender, EventArgs e) { goods = GoodService.GetProcessingGood(); announedGoods = GoodService.GetAnnouncedGood(); }
public HomeController() { categoryService = new CategoryService(); goodService = new GoodService(); blobService = new BlobService(); }
public GoodController(GoodService service) { _service = service; }