Exemple #1
0
        public async Task Test_Add_AllPropertiesHaveValues()
        {
            var mapperConfig = new MapperConfiguration(mc =>
            {
                mc.AddProfile(new Mappings.AutoMapperPictureProfile());
            });

            var request = new PictureRequest
            {
                Id              = "dsadas",
                Name            = "name",
                AppPath         = "app\\path",
                OriginalPath    = "orig\\path",
                FolderName      = "folderName",
                FolderAppPath   = "folderAppPath",
                FolderSortOrder = 365,
                Size            = 39943,
                Tags            = new List <string> {
                    "tag1, tag2"
                },
                CreateTimestamp = DateTime.Now
            };

            var service  = new PictureService(new PictureRepositoryMock(), new TagRepositoryMock(), mapperConfig.CreateMapper(), new MetadataServiceMock());
            var response = await service.Add(request);

            AssertAllPropertiesHaveValues(response);
        }
Exemple #2
0
        public async Task Test_Add_WithDetectedObjects()
        {
            var mapperConfig = new MapperConfiguration(mc =>
            {
                mc.AddProfile(new Mappings.AutoMapperPictureProfile());
            });

            var request = new PictureRequest
            {
                Id              = "dsadas",
                Name            = "name",
                AppPath         = "app\\path",
                OriginalPath    = "orig\\path",
                FolderName      = "folderName",
                FolderAppPath   = "folderAppPath",
                FolderSortOrder = 365,
                Size            = 39943,
                Tags            = new List <string> {
                    "tag1, tag2"
                },
                CreateTimestamp = DateTime.Now,
                DetectedObjects = new List <string> {
                    "object1", "object2", "object3"
                }
            };

            var service  = new PictureService(new PictureRepositoryMock(), new TagRepositoryMock(), mapperConfig.CreateMapper(), new MetadataServiceMock());
            var response = await service.Add(request);

            Assert.AreEqual(3, response.DetectedObjects.Count());
        }
Exemple #3
0
        public ActionResult UrunDetayi(Product product, HttpPostedFileBase[] files)
        {
            var prdct = productservice.Find(x => x.Id == product.Id).FirstOrDefault();

            prdct.Id       = product.Id;
            prdct.UrunAdi  = product.UrunAdi;
            prdct.Aciklama = product.Aciklama;
            prdct.Fiyat    = product.Fiyat;
            prdct.pictures = product.pictures;
            productservice.SaveChanges();

            ViewBag.categoryservice = categoryservice.GetAll();
            ViewBag.brandservice    = brandservice.GetAll();
            ViewBag.pictureservice  = pictureservice.GetAll();


            //var pictures = pictureservice.GetAll();
            //foreach (var itempicture in pictures)
            //{
            //    pictureservice.Remove(itempicture);
            //}



            //iterating through multiple file collection


            foreach (HttpPostedFileBase file in files)
            {
                //Checking file is available to save.
                if (file != null)
                {
                    var InputFileName  = Path.GetFileName(file.FileName);
                    var ServerSavePath = Path.Combine(Server.MapPath("~/Content/NiceAdmin/img/") + InputFileName);
                    //Save file to server folder
                    file.SaveAs(ServerSavePath);
                    //assigning file uploaded status to ViewBag for showing message to user.
                    ViewBag.UploadStatus = files.Count().ToString() + " Fotoğraf başarılı bir şekilde eklendi.";

                    pictureservice.Add(new Picture {
                        ProductId = product.Id, PictureUrl = "/Content/NiceAdmin/img/" + file.FileName, Sort = 1
                    });
                    pictureservice.SaveChanges();
                }
            }



            return(View(product));
        }