Beispiel #1
0
 /// <summary>
 /// Upload image to server
 /// </summary>
 /// <param name="model">Model to upload</param>
 /// <typeparam name="T">Type of image</typeparam>
 /// <returns>Rezult uploading</returns>
 private async Task <IActionResult> Upload <T>(T model) where T : UploadImageModel
 {
     if (ModelState.IsValid)
     {
         Guid userid = GetUserId();
         (object, int, string)rez = ("", 200, "");
         if (model is UploadImageFileModel)
         {
             rez = await _mainControllerService.UploadImageFromFile(model as UploadImageFileModel, userid);
         }
         else if (model is UploadImageURLModel)
         {
             rez = await _mainControllerService.UploadImageFromURL(model as UploadImageURLModel, userid);
         }
         else if (model is UploadImageMapModel)
         {
             rez = await _mainControllerService.UploadImageFromMaps(model as UploadImageMapModel, userid);
         }
         return(JSON(rez.Item1, rez.Item2, rez.Item3));
     }
     else
     {
         return(JSON("", 400, GetErrorsKeys()));
     }
 }
Beispiel #2
0
        ///WARNING! Need enternet
        public async Task MapBingUploadTest()
        {
            var cd    = Directory.GetCurrentDirectory();
            var model = new UploadImageMapModel
            {
                Latitude  = 55,
                Longitude = 48,
                Scale     = 17,
                Zoom      = 17,
                MapType   = MapTypes.Bing
            };
            var ret = await MainControllerService.UploadImageFromMaps(model, Guid.Empty);

            Assert.True(File.Exists(cd + "\\images\\101.bmp"));
            var expected = (new { resultImagePath = "\\images\\101.bmp" }, 200, "");

            Assert.Equal(expected.Item2, ret.Item2);
            Assert.Equal(expected.Item3, ret.Item3);
            Assert.Equal(expected.Item1.GetHashCode(), ret.Item1.GetHashCode());
            File.Delete(cd + "\\images\\101.bmp");
        }