Ejemplo n.º 1
0
 public ActionResult JsonAddNewNormalPhoto(PhotoViewModel newPhoto)
 {
     var uploadResult = UploadFiles();
     if (uploadResult.Count > 0)
     {
         newPhoto.FileName = uploadResult[0].name;
         newPhoto.ImageUrl = uploadResult[0].url;
         var result = _photoManager.AddNewPhoto(new PhotoViewModelMapper().Map(newPhoto));
         if (result.PictureId > 0)
             uploadResult[0].createdPicture = result;
     }
     return Json(uploadResult, JsonRequestBehavior.AllowGet);
 }
 internal Picture Map(PhotoViewModel viewModel)
 {
     var picture = new Picture
                         {
                             FileName = viewModel.FileName,
                             OwnerName = viewModel.OwnerName,
                             Title = viewModel.Title,
                             Description = viewModel.Description,
                             PictureSourceId = viewModel.SourceId,
                             ImageUrl = viewModel.ImageUrl
                         };
     return picture;
 }
 internal PhotoViewModel Map(Picture pic, UrlHelper url)
 {
     var picture = new PhotoViewModel
     {
         PictureId = pic.PictureId.ToString(),
         FileName = pic.FileName,
         OwnerName = pic.OwnerName,
         Title = pic.Title,
         Description = pic.Description,
         SourceId = pic.PictureSourceId,
         ImageUrl = pic.PictureSourceId == 1 ? url.Content("~/Content/Upload/" + pic.FileName) : pic.ImageUrl
     };
     return picture;
 }
Ejemplo n.º 4
0
 public ActionResult JsonAddNewFlickrPhoto(PhotoViewModel newPhoto)
 {
     var result = _photoManager.AddNewPhoto(new PhotoViewModelMapper().Map(newPhoto));
     return Json(result, JsonRequestBehavior.AllowGet);
 }