public ActionResult EditItem(string id) { ItemsBLL ItemBLL = new ItemsBLL(); A_ADM_ITEM_MASTER Item = ItemBLL.GetSingleItemDetails(id); return(View(Item)); }
public ActionResult UpdateItem(A_ADM_ITEM_MASTER item, HttpPostedFileBase newImg) { ItemsBLL ItemBLL = new ItemsBLL(); string Images = ""; if (!string.IsNullOrEmpty(Convert.ToString(newImg))) { if (Request.Files.Count > 0) { int i = 0; HttpPostedFileBase files = Request.Files[i]; if (files.ContentLength > 0) { string filestoragename = Guid.NewGuid().ToString() + ".jpeg"; string directory = Server.MapPath("~/images/"); string path = Path.Combine(directory, filestoragename); files.SaveAs(path); Images = filestoragename; } } item.Item_PicUrl = string.IsNullOrEmpty(Images) ? "/img/default_product.png" : "/images/" + Images; } item.Update_By = Convert.ToString(Session["AdminId"]); bool status = ItemBLL.UpdateItem(item); return(RedirectToAction("Index", "GiftItems")); }
public ActionResult ItemDetails(string id) { ItemsBLL obj = new ItemsBLL(); A_ADM_ITEM_MASTER item = obj.GetSingleItemDetails(id); return(View(item)); }
public ActionResult UnBlockMe(string id) { ItemsBLL obj = new ItemsBLL(); bool status = obj.UnBlockThisItem(id); return(RedirectToAction("Index", "GiftItems")); }
public async Task ItemsBLL_GetItems_Ok() { // Arrange var mockRepo = new Mock <IUnitOfWork>(); var repoMock = new Mock <IRepository <Item> >(); var item = new Item() { Id = 1, ItemName = "Name" }; var item2 = new Item() { Id = 2, ItemName = "Name2" }; var itemList = new List <Item>() { item, item2 }; mockRepo.Setup(x => x.Repository <Item>()) .Returns(repoMock.Object); repoMock.Setup(x => x.Get(null, null, null)) .ReturnsAsync(itemList); var bll = new ItemsBLL(mockRepo.Object); // Act var result = await bll.GetItems(); // Assert Assert.Equal(itemList.Count, result.ToList().Count); }
public ActionResult AddNewItem(Admin_Items item, HttpPostedFileBase imgFile) { string Images = ""; if (Request.Files.Count > 0) { int i = 0; HttpPostedFileBase files = Request.Files[i]; if (files.ContentLength > 0) { string filestoragename = Guid.NewGuid().ToString() + ".jpeg"; string directory = Server.MapPath("~/images/"); string path = Path.Combine(directory, filestoragename); files.SaveAs(path); Images = filestoragename; } } item.Media_Id_Img = string.IsNullOrEmpty(Images) ? "/img/default_product.png" : "/images/" + Images; item.Created_by = Convert.ToString(Session["AdminId"]); item.Updated_by = Convert.ToString(Session["AdminId"]); ItemsBLL obj = new ItemsBLL(); bool res = obj.InsertNewItem(item); return(RedirectToAction("Index", "GiftItems")); }
public ActionResult DashBoard() { DashboardGroup details = new DashboardGroup(); DashboardTotals tempTotal = new DashboardTotals(); MembersBLL memBLL = new MembersBLL(); EventsBLL eveBLL = new EventsBLL(); ItemsBLL iteBLL = new ItemsBLL(); List <DashboardEvents> eves = new List <DashboardEvents>(); List <DashboardVendors> vends = new List <DashboardVendors>(); tempTotal.TotalMembers = memBLL.MembersCount(); tempTotal.TotalEvents = eveBLL.EventsCount(); tempTotal.TotalItems = iteBLL.ItemsCount(); tempTotal.TotalVendors = "0000"; vends.Add(new DashboardVendors("1", "Shop1", "Vendor1", DateTime.Now)); vends.Add(new DashboardVendors("2", "Shop2", "Vendor2", DateTime.Now)); vends.Add(new DashboardVendors("3", "Shop3", "Vendor3", DateTime.Now)); vends.Add(new DashboardVendors("4", "Shop4", "Vendor4", DateTime.Now)); vends.Add(new DashboardVendors("5", "Shop1", "Vendor5", DateTime.Now)); details.Totals = tempTotal; details.Members = memBLL.Recent5Members(); details.Events = eveBLL.Recent5Events(); details.Items = iteBLL.Recent5Items(); details.Vendors = vends.ToArray(); return(View(details)); }
public async Task ItemsBLL_ComputeTotalPriceAsync_PrivilagedUser_ItemNotDisounted() { // Arrange var mockRepo = new Mock <IUnitOfWork>(); var userRepoMock = new Mock <IRepository <User> >(); var userDiscountRepoMock = new Mock <IRepository <UserDiscount> >(); mockRepo.Setup(x => x.Repository <User>()) .Returns(userRepoMock.Object); userRepoMock.Setup(x => x.Get(It.IsAny <Expression <Func <User, bool> > >(), It.IsAny <Func <IQueryable <User>, IOrderedQueryable <User> > >(), It.IsAny <string[]>())) .ReturnsAsync(new List <User>() { new User() { Id = 1, UserCategory = JeweleryStore.Common.Enums.UserType.Privileged } }); mockRepo.Setup(x => x.Repository <UserDiscount>()) .Returns(userDiscountRepoMock.Object); userDiscountRepoMock.Setup(x => x.Get(It.IsAny <Expression <Func <UserDiscount, bool> > >(), It.IsAny <Func <IQueryable <UserDiscount>, IOrderedQueryable <UserDiscount> > >(), It.IsAny <string[]>())) .ReturnsAsync(new List <UserDiscount>() { }); var bll = new ItemsBLL(mockRepo.Object); // Act var result = await bll.ComputeTotalPriceAsync(20, 5, 2, JeweleryStore.Common.Enums.UserType.Privileged, "name"); // Assert Assert.Equal(100, result); }
// GET: GiftItems public ActionResult Index() { ItemsBLL obj = new ItemsBLL(); A_ADM_ITEM_MASTER[] items = obj.GetAllItemsDetails(); if (items != null) { return(View(items)); } return(View()); }
public async Task ItemsBLL_GetItemById_IdNotPresent() { // Arrange var mockRepo = new Mock <IUnitOfWork>(); var repoMock = new Mock <IRepository <Item> >(); mockRepo.Setup(x => x.Repository <Item>()) .Returns(repoMock.Object); repoMock.Setup(x => x.GetByIdAsync(It.IsAny <int>())) .ReturnsAsync(null as Item); var controller = new ItemsBLL(mockRepo.Object); // Act var result = await controller.GetItemById(1); // Assert Assert.Null(result); }
public async Task ItemsBLL_GetItemById_Present() { // Arrange var mockRepo = new Mock <IUnitOfWork>(); var repoMock = new Mock <IRepository <Item> >(); var item = new Item() { Id = 1, ItemName = "Name" }; mockRepo.Setup(x => x.Repository <Item>()) .Returns(repoMock.Object); repoMock.Setup(x => x.GetByIdAsync(It.IsAny <int>())) .ReturnsAsync(item); var controller = new ItemsBLL(mockRepo.Object); // Act var result = await controller.GetItemById(1); // Assert Assert.Equal(item.Id, result.Id); Assert.Equal(item.ItemName, result.ItemName); }
/// <summary> /// 按关键词导入,每个关键词只能查询100条 /// </summary> public static void ImportAllTaobaoke() { var dt = DateTime.Now; PageInfo page = new PageInfo(); page.PageSize = 100; var cateItems = ItemCateBLL.GetData(); foreach (var item in cateItems) { if (item.LastUpdateTime > dt.AddDays(-10)) { continue; } Func <string, object> fun = (keyword) => { try { List <Items> updateItems = new List <Items>(200); List <Items> addItems = new List <Items>(200); var items = ItemsBLL.GetByTag(keyword); page.PageIndex = 1; var result = QueryCoupon(item.CateName); //Timeout timeout = new Timeout(); //timeout.Do = QueryCoupon(item.CateName); if (result == null || result.Count() == 0) { return(null); } foreach (var item2 in result) { var temp = items.FirstOrDefault(a => a.NumIid == item2.NumIid); if (temp != null) { item2.Id = temp.Id; temp = item2; if (updateItems.Exists(d => d.NumIid == temp.NumIid)) { updateItems.Add(temp); } } else { items.Add(item2); addItems.Add(item2); } } item.LastUpdateTime = dt; Task.Factory.StartNew(() => { if (addItems.Count > 0) { ItemsBLL.BatchInsert(addItems); } if (updateItems.Count > 0) { ItemsBLL.BatchUpdate(updateItems); } ItemCateBLL.Update(item); }); } catch (Exception ex) { Logger.WriteErrorLog(ex.Message); } return(null); }; FuncTimeout.EventNeedRun action = delegate(object[] param) { //调用自定义函数 return(fun(param[0].ToString())); }; FuncTimeout ft = new FuncTimeout(action, 1000 * 60 * 2);//超时时间2分钟 ft.doAction(item.CateName); Thread.Sleep(5000); } try { //ItemCateBLL.BatchUpdate(cateItems); ItemsBLL.ClearSameData(); Console.WriteLine("Done:" + DateTime.Now); } catch (Exception ex) { Logger.WriteErrorLog(ex.Message); } //TaskParallelHelper.ExecuteTask(actionItem); }
/// <summary> /// 没有关键词,导入前一万条 /// </summary> public static void ImportTaobaoke() { var dt = DateTime.Now; Func <int, object> fun = (pageIndex) => { try { List <Items> updateItems = new List <Items>(200); List <Items> addItems = new List <Items>(200); var items = ItemsBLL.GetData(); var result = QueryCoupon(string.Empty, pageIndex); if (result == null || result.Count() == 0) { return(null); } foreach (var item2 in result) { var temp = items.FirstOrDefault(a => a.NumIid == item2.NumIid); if (temp != null) { item2.Id = temp.Id; temp = item2; if (updateItems.Exists(d => d.NumIid == temp.NumIid)) { updateItems.Add(temp); } } else { items.Add(item2); addItems.Add(item2); } } Task.Factory.StartNew(() => { if (addItems.Count > 0) { ItemsBLL.BatchInsert(addItems); } if (updateItems.Count > 0) { ItemsBLL.BatchUpdate(updateItems); } }); } catch (Exception ex) { Logger.WriteErrorLog(ex.Message); } return(null); }; for (int i = 1; i <= 100; i++) { FuncTimeout.EventNeedRun action = delegate(object[] param) { //调用自定义函数 return(fun(param[0].ToString().TryToInt())); }; FuncTimeout ft = new FuncTimeout(action, 1000 * 60 * 1);//超时时间2分钟 ft.doAction(i); Thread.Sleep(5000); } try { ItemsBLL.ClearSameData(); Console.WriteLine("Done:" + DateTime.Now); } catch (Exception ex) { Logger.WriteErrorLog(ex.Message); } }