public JsonResult UpdateShop(Common.Shop obj) { try { ShopsBusiness _shopsBusiness = new ShopsBusiness(); var objentity = _shopsBusiness.GetById(obj.Id); objentity.Id = obj.Id; objentity.ShopName = obj.ShopName; objentity.Icon = obj.Icon; objentity.Address = obj.Address; objentity.LocationId = obj.LocationId; objentity.Phone = obj.Phone; objentity.Rate = obj.Rate; objentity.TotalView = obj.TotalView; objentity.Type = obj.Type; objentity.Status = obj.Status; objentity.BeginDate = obj.BeginDate; objentity.EndDate = obj.EndDate; objentity.ActiveDate = obj.ActiveDate; objentity.CreateDate = obj.CreateDate; objentity.ModifyDate = DateTime.Now; _shopsBusiness.Edit(objentity); return(Json(1));//Cập nhật thành công } catch (Exception) { throw; } }
public void Write(Common.Shop shop, string outputPath) { var results = new List <Item>(); var current = new Item(); foreach (var sell in _sell) { var matched = MatchingHelper.Match(sell, _cost); var sku = shop == Common.Shop.Lazada ? sell.SKU : sell.Model; results.Add(new Item() { LazName = sell.Name, SKU = sku, Sell = sell.Price, Cost = matched.Matched ? matched.Price : 0, Matched = matched.Matched, IsOverPrice = matched.Matched ? matched.Price > sell.Price : false, Amount = sell.Amount, CostType = matched.Matched ? matched.CostType : string.Empty }); } using (FileStream stream = new FileStream(outputPath, FileMode.CreateNew, FileAccess.Write)) { var workbook = new XSSFWorkbook(); var sheet = workbook.CreateSheet("profit"); var row = 0; var headerRow = sheet.CreateRow(row); headerRow.CreateCell(0).SetCellValue("lazName"); headerRow.CreateCell(1).SetCellValue("SKU"); headerRow.CreateCell(2).SetCellValue("Sell"); headerRow.CreateCell(3).SetCellValue("Cost"); headerRow.CreateCell(4).SetCellValue("Matched"); headerRow.CreateCell(5).SetCellValue("Over Price"); headerRow.CreateCell(6).SetCellValue("Type"); headerRow.CreateCell(7).SetCellValue("Amount"); foreach (var result in results) { var rowtemp = sheet.CreateRow(++row); rowtemp.CreateCell(0).SetCellValue(result.LazName); rowtemp.CreateCell(1).SetCellValue(result.SKU); rowtemp.CreateCell(2).SetCellValue(result.Sell.ToString(CultureInfo.InvariantCulture)); rowtemp.CreateCell(3).SetCellValue(result.Cost.ToString(CultureInfo.InvariantCulture)); rowtemp.CreateCell(4).SetCellValue(result.Matched ? "" : "NO"); rowtemp.CreateCell(5).SetCellValue(result.IsOverPrice ? "YES" : ""); rowtemp.CreateCell(6).SetCellValue(result.CostType); rowtemp.CreateCell(7).SetCellValue(result.Amount.ToString(CultureInfo.InvariantCulture)); } workbook.Write(stream); } }
public void Write(Common.Shop shop, string outputPath) { switch (shop) { case Common.Shop.Lazada: WriteLazada(outputPath); break; } }
public void GetShops() { var oldShop = new Common.Shop() { NameShop = "Lime", PhoneShop = "+7909323232", City = "Saratov" }; int id = logic.AddShop(oldShop); var shops = logic.GetShops(); Assert.IsNotNull(shops.GetEnumerator()); int count = 0; foreach (Common.Shop s in shops) { count++; } Assert.AreEqual(count, 1); }
public void AddShop() { var oldShop = new Common.Shop() { NameShop = "Lime", Address = "Зарубина", DescriptionShop = "Кафе", Website = "lime.ru", Rating = 0, PhoneShop = "+7909323232", City = "Saratov", OpeningHours = "9:00-21:00" }; int id = logic.AddShop(oldShop); var shop = logic.GetShopById(id); Assert.IsNotNull(shop, "Shop is null"); Assert.AreEqual(Common.Shop.ToString(oldShop), Common.Shop.ToString(shop), "Не совпали названия магазинов при добавлении"); }
public void Update() { var oldShop = new Common.Shop() { NameShop = "Lime", Address = "Зарубина", DescriptionShop = "Кафе", Website = "lime.ru", Rating = 0, PhoneShop = "+7909323232", City = "Saratov", OpeningHours = "9:00-21:00" }; int id = logic.AddShop(oldShop); Common.Shop shop = logic.GetShopById(id); shop.NameShop = "For update"; logic.Update(shop); Assert.AreEqual(Common.Shop.ToString(logic.GetShopById(id)), Common.Shop.ToString(shop), "Adding data about shop incorrect"); logic.DeleteById(id); }
public JsonResult GetInforShop(long id) { try { var obj = _shopsBussiness.GetById(id); if (obj != null) { Common.Shop objentity = new Common.Shop(); objentity.Id = obj.Id; objentity.ShopName = obj.ShopName; objentity.Icon = obj.Icon; objentity.Address = obj.Address; objentity.LocationId = obj.LocationId; objentity.Phone = obj.Phone; objentity.Rate = obj.Rate; objentity.TotalView = obj.TotalView; objentity.Type = obj.Type; objentity.Status = obj.Status; objentity.BeginDate = obj.BeginDate; objentity.EndDate = obj.EndDate; objentity.ActiveDate = obj.ActiveDate; objentity.CreateDate = obj.CreateDate; objentity.ModifyDate = obj.ModifyDate; // // Common.ShopSupport shopSupport = new Common.ShopSupport(); objentity.Email = obj.ShopSupport.Email; objentity.Skype = obj.ShopSupport.Skype; objentity.Facebook = obj.ShopSupport.Facebook; //get số sản phẩm và số đơn hàng của shop var numProductOfShopDb = _productsBusiness.GetDynamicQuery().Count(x => x.MemberId == id); if (numProductOfShopDb != 0) { objentity.NumberOfProduct = numProductOfShopDb; } else { objentity.NumberOfProduct = 0; } var numOrderOfShopDb = _ordersBusiness.GetDynamicQuery().Count(x => x.IdShop == id); if (numOrderOfShopDb != 0) { objentity.NumberOfOrder = numOrderOfShopDb; } else { objentity.NumberOfOrder = 0; } return(Json(objentity, JsonRequestBehavior.AllowGet)); } else { return(Json(0)); } } catch (Exception) { //Write log throw; } }
public File(Common.Shop shop, Common.Type type) { _shop = shop; _type = type; }