public void GetProducts_ReturnsAllProducts_WhenIdsAreNotProvided() { //Arrange var products = new List <Product> { new Product { CatalogNumber = 1 }, new Product { CatalogNumber = 2 } }; var productsRepositoryMock = new Mock <IProductsRepository>(); productsRepositoryMock .Setup(x => x.GetAllAsync()) .Returns(Task.FromResult(products as IEnumerable <Product>)); var service = new ProductsServices(productsRepositoryMock.Object); var request = new GetProducts(); //Act var response = (GetProductsResponse)service.GetAsync(request).Result; //Assert Assert.AreEqual(2, response.Products.Count); Assert.AreEqual(1, response.Products[0].CatalogNumber); Assert.AreEqual(2, response.Products[1].CatalogNumber); }
public ActionResult GetSKUList(SKU_Query_Model model) { try { var ccl = new CommonController(); var useInfo = ccl.GetCurrentUserbyCookie(Request[ConfigurationManager.AppSettings["userInfoCookiesKey"]]); var pSvr = new ProductsServices(); var totalRecord = 0; var list = new ProductCommonServices().GetProductInventorys(model, out totalRecord, useInfo); return(Json(new NBCMSResultJson { Status = StatusType.OK, Data = new { total = totalRecord, rows = list } })); } catch (Exception ex) { NBCMSLoggerManager.Fatal(ex.Message); NBCMSLoggerManager.Fatal(ex.StackTrace); NBCMSLoggerManager.Error(""); return(Json(new NBCMSResultJson { Status = StatusType.Exception, Data = ex.Message })); } }
/// <summary> /// 复制产品。 /// Change:由先来的单个Channel的复制,改成现在的多个渠道一起复制,Lee 2013年12月6日10:29:05 /// </summary> /// <returns></returns> public ActionResult DuplicateMultipleNewSku(long skuid, int newBrandId, string newSkuOrder, List <int> channelList, User_Profile_Model userModel) { try { //User_Profile_Model userModel = new CommonController().GetCurrentUserbyCookie(Request[ConfigurationManager.AppSettings["userInfoCookiesKey"]]); var pSvr = new ProductsServices(); string msg; var retVal = pSvr.DuplicateMultipleNewSKU(skuid, newSkuOrder, newBrandId, channelList, userModel.User_Account, out msg); if (!retVal) { return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = msg == "" ? "failed to duplicate new SKU" : msg })); } return(Json(new NBCMSResultJson { Status = StatusType.OK, Data = msg == "Duplicate Product Successfully" ? "" : msg })); } catch (Exception ex) { NBCMSLoggerManager.Error(ex.Message); NBCMSLoggerManager.Error(ex.Source); NBCMSLoggerManager.Error(ex.StackTrace); return(Json(new NBCMSResultJson { Status = StatusType.Exception, Data = ex.Message })); } }
public void CreateProduct_DoesNotThrow_WhenProductDoesNotAlreadyExist() { //Arrange var productsRepositoryMock = new Mock <IProductsRepository>(); productsRepositoryMock .Setup(x => x.AddAsync(It.IsAny <Product>())) .Returns(Task.CompletedTask); productsRepositoryMock .Setup(x => x.GetByIdsAsync(It.IsAny <int[]>())) .Returns(Task.FromResult(new List <Product>() as IEnumerable <Product>)); var service = new ProductsServices(productsRepositoryMock.Object); var createProduct = new CreateProduct { CatalogNumber = 1, Price = 10, Quantity = 100, Name = "Winter Jacket", Category = "Jackets", Vendor = "Nike" }; //Act var createProductTask = service.PostAsync(createProduct); //Assert Assert.DoesNotThrowAsync(() => createProductTask); }
public ActionResult ProductConfiguration(long skuid, User_Profile_Model userModel) { if (skuid < 1) { return(View()); } var psrv = new ProductsServices(); var model = psrv.GetSingleSKU(skuid); //model.userInfo = new CommonController().GetCurrentUserbyCookie(Request[ConfigurationManager.AppSettings["userInfoCookiesKey"]]); model.userInfo = userModel; ViewBag.SKUInfo = new JavaScriptSerializer().Serialize(model);//把强类型对象传递到前端,提供JS脚本each统计箱柜尺寸信息... model.RelatedProducts = psrv.GetRelatedWebsitProducts(skuid, model.userInfo); //WL-1 -start //model.CMSImgUrl = ConfigurationManager.AppSettings["CMSImgUrl"]; // model.CMSImgUrl = Request.Url.Scheme+"://" + Request.Url.Host + ":" + Request.Url.Port + "/MediaLib/Files/"; if (Request.Url != null) { model.CMSImgUrl = Request.Url.Scheme + "://" + Request.Url.Authority + Request.ApplicationPath + "/MediaLib/Files/"; } //WL-1 -end model.StatusList = new CMSCacheableDataController().SkuStatusListObject();//2014年5月13日10:58:37 return(View(model)); }
/// <summary> /// 更新HMNUMCosting的信息,用于HMNUM Configuration页面的的Costing的编辑更新 /// 需要注意的是每一次的跟新都将在库表新增一条价格信息,影响将来报表的生成。 /// 虽然和HMNUMController页面的方法一样,但是还是分开维护,因为2个展示有可能不同,遇到需求变动会变得痛苦! /// CreateDate:2013年11月14日11:19:26 /// </summary> /// <param name="skuid"></param> /// <param name="costing"></param> /// <param name="retailPrice"></param> /// <param name="userModel"></param> /// <returns></returns> public ActionResult EditSkuCosting(long skuid, CMS_SKU_Costing_Model costing, decimal?retailPrice, User_Profile_Model userModel) { try { //User_Profile_Model userModel = new CommonController().GetCurrentUserbyCookie(Request[ConfigurationManager.AppSettings["userInfoCookiesKey"]]); var pSvr = new ProductsServices(); if (!pSvr.EditSKUCosting(skuid, ref costing, userModel.User_Account, retailPrice)) { return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = "Fail to udate current HM#'s costing" })); } return(Json(new NBCMSResultJson { Status = StatusType.OK, Data = costing })); } catch (Exception ex) { NBCMSLoggerManager.Error(""); NBCMSLoggerManager.Error(ex.Message); NBCMSLoggerManager.Error(ex.StackTrace); NBCMSLoggerManager.Error(""); return(Json(new NBCMSResultJson { Status = StatusType.Exception, Data = ex.Message })); } }
private async void ListProducts_Tapped(object sender, TappedRoutedEventArgs e) { Windows.UI.Popups.MessageDialog message; try { Cueros.App.Core.Models.Product _objeto = null; var listProducts = await ProductsServices.GetProducts(); if (ListProducts.SelectedItem != null) { var _idProducto = (ListProducts.SelectedItem as Product).ProductID; var result = from item in listProducts where item.ProductID == _idProducto select item; _objeto = result.ToList().FirstOrDefault(); Frame.Navigate(typeof(Materiales), _objeto); } else { message = new Windows.UI.Popups.MessageDialog("Seleccione un producto", "Seleccion"); await message.ShowAsync(); } } catch (Exception ex) { message = new Windows.UI.Popups.MessageDialog(ex.Message.ToString()); message.ShowAsync(); } }
async void ProductOfCategories() { try { pgrBar.Visibility = Visibility.Visible; Categorias.Opacity = 0; List <Product> All = await ProductsServices.GetProductsFromThisCategory(cate); Todos.ItemsSource = All; List <Product> Nov = await ProductsServices.GetRecentProductsFromThisCategory(cate); Novedades.ItemsSource = Nov; List <Product> Des = await ProductsServices.GetRecentProductsFromThisCategory(cate); Destacados.ItemsSource = Des; pgrBar.Visibility = Visibility.Collapsed; textb.Visibility = Visibility.Collapsed; Categorias.Opacity = 1; } catch (Exception) { List <Product> get_list = new List <Product>(); get_list.Add(new Product() { Name = "O.o oops, ahora no podemos conextarnos, intenta más tarde" }); Todos.ItemsSource = get_list; Novedades.ItemsSource = get_list; Destacados.ItemsSource = get_list; } }
// // GET: /SKUConfiguration/ public ActionResult Index(User_Profile_Model userModel) { //var model = new CMS_SKU_Model {userInfo = userModel}; var model = new ProductsServices().GetSingleSKU(1); model.userInfo = userModel; ViewBag.SKUInfo = new JavaScriptSerializer().Serialize(model);//把强类型对象传递到前端,提供JS脚本each统计箱柜尺寸信息... model.RelatedProducts = new ProductsServices().GetRelatedWebsitProducts(1, model.userInfo); return(View(model)); }
/// <summary> /// 为颜色材料类别MCCC四个字段获取智能提示下拉单 /// CreatedDate:2014年3月26日10:28:11 /// </summary> /// <param name="term"></param> /// <param name="type"></param> /// <param name="ParentID">只有查询SubCategory的时候这个字段才有意义</param> /// <returns></returns> // ReSharper disable InconsistentNaming public ActionResult GetAutoCompeltedMCCC(string term, string type, long ParentID) // ReSharper restore InconsistentNaming { var pSrv = new ProductsServices(); return(Json(new NBCMSResultJson { Status = StatusType.OK, Data = pSrv.GetAutoCompeltedMCCC(term, type, ParentID) })); }
public async void Serializar() { await ApplicationData.Current.LocalFolder.CreateFileAsync("Cadepia.xml", CreationCollisionOption.ReplaceExisting); using (Stream stream = await ApplicationData.Current.LocalFolder.OpenStreamForWriteAsync("Cadepia.xml", CreationCollisionOption.ReplaceExisting)) { var _list = await ProductsServices.GetProducts(); XmlSerializer serializer = new XmlSerializer(_list.GetType()); serializer.Serialize(stream, _list); await stream.FlushAsync(); } }
public async void obtenerproductos() { try { List<Product> pro = await ProductsServices.GetProductsFromThisCategory(id); productos = new ObservableCollection<Product>(pro); new Almacenar<Product>().Serialize(productos, categoria + "_productos.json"); lstproductos.ItemsSource = pro; } catch (Exception) { } }
public async void obtenerdestacados() { try { List<Product> des = await ProductsServices.GetTopProductsFromThisCategory(id, 10); destacados = new ObservableCollection<Product>(des); new Almacenar<Product>().Serialize(destacados, categoria + "_destacados.json"); lstdestacados.ItemsSource = des; } catch (Exception) { } }
public async void obtenernovedades() { try { List<Product> nov = await ProductsServices.GetRecentProductsFromThisCategory(id, 10); novedades = new ObservableCollection<Product>(nov); new Almacenar<Product>().Serialize(novedades, categoria + "_novedades.json"); lstnovedades.ItemsSource = nov; } catch (Exception) { } }
public async void ListProduct() { AnilloProgreso.Visibility = Visibility.Visible; var listProducts = await ProductsServices.GetProducts(); try { ListProducts.ItemsSource = listProducts; Serializar(); AnilloProgreso.Visibility = Visibility.Collapsed; } catch (Exception) { ErrorConexion(); AnilloProgreso.Visibility = Visibility.Collapsed; } }
public async void obtenerdestacados() { try { List <Product> pro = await ProductsServices.GetTopProducts(10); destacados = new ObservableCollection <Product>(pro); new Almacenar <Product>().Serialize(destacados, "destacados.json"); if (destacados != null && destacados.Count != 0) { lstdestacados.ItemsSource = destacados; } } catch (Exception) { //MessageBox.Show("no inter"); } }
public async void obtenernovedades() { try { List <Product> pro = await ProductsServices.GetRecentProducts(10); novedades = new ObservableCollection <Product>(pro); new Almacenar <Product>().Serialize(novedades, "novedades.json"); if (novedades != null && novedades.Count != 0) { lstnovedades.ItemsSource = novedades; } } catch (Exception) { //MessageBox.Show("no inter"); } }
public void Get_WhenCalledWithNoParameters_ShouldReturnOkObjectResult() { // Arrange var testDataContext = new DataFileData(); var repository = new ProductsRepository(new DatabaseFactory(testDataContext)); var productsServicesInst = new ProductsServices(repository); //var mockStaticLoggerInstWrapper = new Mock<IStaticLoggerInstanceWrapper>(); var productsController = new ProductsController(productsServicesInst); // Act var response = productsController.Get(); // Assert Assert.IsNotNull(response); Assert.IsInstanceOfType(response, typeof(ObjectResult)); }
/// <summary> /// /// </summary> /// <param name="model"></param> /// <param name="userModel"></param> /// <returns></returns> public ActionResult UpdateSellPack(SKU_HM_Relation_Model model, User_Profile_Model userModel) { try { if (model.SKUID < 1 || model.StockKeyID < 1 || model.ProductID < 1)//2013年11月26日10:35:58 { return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = "Request parameters are illegal" })); } var pSvr = new ProductsServices(); string msg; // User_Profile_Model userModel = new CommonController().GetCurrentUserbyCookie(Request[ConfigurationManager.AppSettings["userInfoCookiesKey"]]); if (pSvr.UpdateSellPack(model, out msg, userModel)) { return(Json(new NBCMSResultJson { Status = StatusType.OK, Data = "OK" })); } return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = msg == "" ? "failed to insert new Product Pieces" : msg })); } catch (Exception ex) { NBCMSLoggerManager.Error(ex.Message); NBCMSLoggerManager.Error(ex.Source); return(Json(new NBCMSResultJson { Status = StatusType.Exception, Data = ex.Message })); } }
private async void loadProduct() { GenericResponse productsResponse = await ProductsServices.GetList(txtProducto.Text); if (productsResponse.Items.Count == 0) { var dialog = new MessageDialog("No se encontraron registros"); await dialog.ShowAsync(); } else if (productsResponse.Items.Count == 1) { product_selected((ProductService)productsResponse.Items[0]); } else { lstProductos.Visibility = Visibility.Visible; lstProductos.ItemsSource = productsResponse.Items; } }
public void Post_WhenPassedNullProduct_ShouldReturnBadRequest() { // Arrange var testDataContext = new DataFileData { Products = _testProducts }; var productsRepository = new ProductsRepository(new DatabaseFactory(testDataContext)); var productsServicesInst = new ProductsServices(productsRepository); //var mockStaticLoggerInstWrapper = new Mock<IStaticLoggerInstanceWrapper>(); var productsController = new ProductsController(productsServicesInst); // Act var response = productsController.Post(null); // Assert Assert.IsNotNull(response); Assert.IsInstanceOfType(response, typeof(BadRequestResult)); }
/// <summary> /// 注意没有调用try catch /// </summary> /// <param name="mcModel"></param> /// <returns></returns> // ReSharper disable InconsistentNaming public ActionResult CheckMCC(MCCC mcModel) // ReSharper restore InconsistentNaming { var pSvr = new ProductsServices(); var msg = string.Empty; if (pSvr.CheckMCC(mcModel, ref msg)) { return(Json(new NBCMSResultJson { Status = StatusType.OK, Data = "" })); } return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = msg })); }
async void MainPage_Loaded(object sender, RoutedEventArgs e) { List <Product> products = await ProductsServices.GetProducts(); MessageBox.Show(products.Count.ToString()); //lstCategorias.ItemsSource = await CategoriesServices.GetListOfCategories(); //List<Supplier> suppliers = await SuppliersServices.GetSuppliers(); //MessageBox.Show(suppliers.Count.ToString()); //Supplier supplier = await SuppliersServices.GetSupplier(4); //MessageBox.Show(supplier.Name); //List<Material> materials = await MaterialsServices.GetMaterials(); //MessageBox.Show(materials.Count.ToString()); //List<Picture> pictures = await PicturesServices.GetPictures(); //MessageBox.Show(pictures.Count.ToString()); }
/// <summary> /// 删除掉网站产品和其中一张图像的关系 /// </summary> /// <param name="skuid"></param> /// <param name="mediaId"></param> /// <param name="userModel"></param> /// <returns></returns> public ActionResult RemoveSkuMedia(long skuid, long mediaId, User_Profile_Model userModel) { try { if (mediaId == 0 || mediaId == 0) { return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = "Request is illegal." })); } var pSvr = new ProductsServices(); //User_Profile_Model userModel =new CommonController().GetCurrentUserbyCookie(Request[ConfigurationManager.AppSettings["userInfoCookiesKey"]]); if (pSvr.RemoveSKUMedia(skuid, mediaId, userModel)) { return(Json(new NBCMSResultJson { Status = StatusType.OK, Data = "Remove Successfully" })); } return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = "failed to remove this image" })); } catch (Exception ex) { NBCMSLoggerManager.Error(ex.Message); NBCMSLoggerManager.Error(ex.Source); return(Json(new NBCMSResultJson { Status = StatusType.Exception, Data = ex.Message })); } }
/// <summary> /// Change1:新增了一个MCCC的模块,你懂得 2014年1月28日16:26:45 /// </summary> /// <param name="model"></param> /// <param name="mcModel"></param> /// <param name="userModel"></param> /// <returns></returns> public ActionResult UpdatedProduct([Bind(Exclude = "SKU")] CMS_SKU_Model model, MCCC mcModel, User_Profile_Model userModel) { try { if (model.SKUID == 0) { return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = "Request is illegal." })); } //User_Profile_Model userModel = new CommonController().GetCurrentUserbyCookie(Request[ConfigurationManager.AppSettings["userInfoCookiesKey"]]); var pSvr = new ProductsServices(); string msg; if (pSvr.UpdatedProduct(model, mcModel, userModel.User_Account, out msg)) { return(Json(new NBCMSResultJson { Status = StatusType.OK, Data = "OK" })); } return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = msg == "update product failed." ? "" : msg })); } catch (Exception ex) { NBCMSLoggerManager.Error(ex.Message); NBCMSLoggerManager.Error(ex.Source); return(Json(new NBCMSResultJson { Status = StatusType.Exception, Data = ex.Message })); } }
public void DeleteProduct_ThrowsHttpError_WhenProductDoesNotExist() { //Arrange var productsRepositoryMock = new Mock <IProductsRepository>(); productsRepositoryMock .Setup(x => x.GetByIdsAsync(It.IsAny <int[]>())) .Returns(Task.FromResult(new List <Product>() as IEnumerable <Product>)); var service = new ProductsServices(productsRepositoryMock.Object); var deleteProduct = new DeleteProduct { CatalogNumber = 1 }; //Act var deleteProductTask = service.DeleteAsync(deleteProduct); //Assert Assert.ThrowsAsync <HttpError>(() => deleteProductTask); }
public void GetById_WhenPassedUnknownId_ShouldReturnNotFoundResult() { // Arrange var testDataContext = new DataFileData { Products = _testProducts }; var theRepository = new ProductsRepository(new DatabaseFactory(testDataContext)); var productsServicesInst = new ProductsServices(theRepository); //var mockStaticLoggerInstWrapper = new Mock<IStaticLoggerInstanceWrapper>(); var productsController = new ProductsController(productsServicesInst); // Act var response = productsController.GetById(0); // Assert Assert.IsNotNull(response); Assert.IsInstanceOfType(response, typeof(NotFoundResult)); }
/// <summary> /// 查找当前HMNUM对于的所有的渠道。用于SKU关联图像的时候多渠道选择使用 /// CreatedDate:2014年2月13日23:04:03 /// Change1:格式返回不再是ChannelID和ChannleName,新增一个SKUID,这样子客户端在选择时候我们可以直接选取SKUID提交到 /// 后台来更新,避免再次以通过ChannelID+HMNUM来查询SKUID! 2014年2月14日10:47:42 /// </summary> /// <returns></returns> public ActionResult GetChannelsByHm(string stockKey) { try { var pSvr = new ProductsServices(); return(Json(new NBCMSResultJson { Status = StatusType.OK, Data = pSvr.GetChannelsByHM(stockKey) })); } catch (Exception ex) { NBCMSLoggerManager.Error(ex.Message); NBCMSLoggerManager.Error(ex.Source); return(Json(new NBCMSResultJson { Status = StatusType.Exception, Data = ex.Message })); } }
public void Get_WhenCalledWithNoParameters_ShouldReturnAllProducts() { // Arrange var testDataContext = new DataFileData { Products = _testProducts }; var repository = new ProductsRepository(new DatabaseFactory(testDataContext)); var productsServicesInst = new ProductsServices(repository); //var mockStaticLoggerInstWrapper = new Mock<IStaticLoggerInstanceWrapper>(); var productsController = new ProductsController(productsServicesInst); // Act var response = productsController.Get(); // Assert var items = (List <ProductItem>)((ObjectResult)response).Value; Assert.AreEqual(3, items.Count); }
///// <summary> ///// 防止这里是为了:(2014年2月27日19:15:01) ///// 1:SKU页面的逻辑已经非常复杂,这一块剥离出来减少复杂度,同时也许以后这个模块会被重复利用; ///// 2:之所以直接引用eCOM.BLL模块仅仅是为了强类型对象的共享。正常应该通过HttpRequest进行通信。 //// 3: Send2eComPath 字段的引入证明了剥离出来的必要性(2014年3月5日) ///// </summary> ///// <param name="SKUID"></param> ///// <returns></returns> public ActionResult SendToEcomByID(long skuid, string imageStoragePath) { var pSvr = new ProductsServices(); var eComSvr = new ICMSECOM.BLL.Insert2EComServices(); var skuModel = pSvr.GetSingleSKU(skuid); var send2EComPath = ""; if (skuModel.pMedia != null) { //imageName = mediaModel.HMNUM + "\\" + mediaModel.ImgName + mediaModel.fileFormat; var imageName = skuModel.pMedia.HMNUM + "\\" + skuModel.pMedia.ImgName + skuModel.pMedia.fileFormat; send2EComPath = Path.Combine(imageStoragePath, imageName); } skuModel.CMSPhysicalPath = imageStoragePath; skuModel.Send2eComPath = send2EComPath; eComSvr.Processing(skuModel); return(Json(new NBCMSResultJson { Status = StatusType.OK, Data = "OK" })); }