示例#1
0
        public IEnumerable <Product> DeserializeProductTest()
        {
            SynchService          synch     = new SynchService();
            XDocument             xDocument = XDocument.Load(@"E:\temp\Products.xml");
            IEnumerable <Product> products  = synch.CreateProductsFromXDocument(xDocument);

            Assert.True(products.Any());
            return(products);
        }
        public ActionResult UploadProductsAsync(IEnumerable <HttpPostedFileBase> attachments)
        {
            foreach (var file in attachments)
            {
                FileType fileType;
                Enum.TryParse(file.ContentType.Replace("text/", String.Empty), out fileType);

                if (fileType != FileType.other && fileType == FileType.xml)
                {
                    HttpPostedFileBase file1 = file;
                    var synch = new SynchService();
                    IEnumerable <Product> products = synch.CreateProductsFromXDocument(XDocument.Load(file1.InputStream));
                    var synchAction = new SynchActionService();
                    ActionHelper.TryExecute(() => synchAction.InsertProductToRepository(products), ModelState);
                }
                else
                {
                    ModelState.AddModelError("NotSupportedFormat", WebStroreResource.NotSupportedFormat);
                    return(Json(new { status = "Error", message = WebStroreResource.NotSupportedFormat }, "text/plain"));
                }
            }
            return(Content(String.Empty));
        }
        public ActionResult UploadProductsAsync(IEnumerable<HttpPostedFileBase> attachments)
        {
            foreach (var file in attachments)
            {
                FileType fileType;
                Enum.TryParse(file.ContentType.Replace("text/", String.Empty), out fileType);

                if (fileType != FileType.other && fileType == FileType.xml)
                {
                    HttpPostedFileBase file1 = file;
                    var synch = new SynchService();
                    IEnumerable<Product> products = synch.CreateProductsFromXDocument(XDocument.Load(file1.InputStream));
                    var synchAction = new SynchActionService();
                    ActionHelper.TryExecute(() => synchAction.InsertProductToRepository(products), ModelState);
                }
                else
                {
                    ModelState.AddModelError("NotSupportedFormat", WebStroreResource.NotSupportedFormat);
                    return Json(new { status = "Error", message = WebStroreResource.NotSupportedFormat }, "text/plain");
                }
            }
            return Content(String.Empty);
        }
示例#4
0
 public IEnumerable<Product> DeserializeProductTest()
 {
     SynchService synch = new SynchService();
     XDocument xDocument = XDocument.Load(@"E:\temp\Products.xml");
     IEnumerable<Product> products = synch.CreateProductsFromXDocument(xDocument);
     Assert.True(products.Any());
     return products;
 }