Inheritance: KnowYourTurf.Core.ViewModel
Esempio n. 1
0
 public ActionResult Display(ViewModel input)
 {
     var photo = _repository.Find<Photo>(input.EntityId);
     var model = new PhotoViewModel
                     {
                         Photo = photo,
                         AddEditUrl = UrlContext.GetUrlForAction<PhotoController>(x => x.AddUpdate(null)) + "/" + photo.EntityId
                     };
     return View(model);
 }
Esempio n. 2
0
 public ActionResult AddUpdate(ViewModel input)
 {
     var photo = input.EntityId > 0 ? _repository.Find<Photo>(input.EntityId) : new Photo();
     var categoryItems = _selectListItemService.CreateList<PhotoCategory>(x=>x.Name,x=>x.EntityId,true);
     var model = new PhotoViewModel
     {
         Photo = photo,
         PhotoCategoryList =categoryItems
     };
     return View(model);
 }
        public ActionResult AddUpdate(ViewModel input)
        {
            var photo         = input.EntityId > 0 ? _repository.Find <Photo>(input.EntityId) : new Photo();
            var categoryItems = _selectListItemService.CreateList <PhotoCategory>(x => x.Name, x => x.EntityId, true);
            var model         = new PhotoViewModel
            {
                Photo             = photo,
                PhotoCategoryList = categoryItems
            };

            return(View(model));
        }
Esempio n. 4
0
        public ActionResult Save(PhotoViewModel input)
        {
            var coId = _httpContextAbstractor.GetCompanyIdFromIdentity();
            var photo = input.Photo.EntityId > 0 ? _repository.Find<Photo>(input.Photo.EntityId) : new Photo();
            var newDoc = mapToDomain(input, photo);
            var serverDirectory = "/CustomerPhotos/" + coId;
            photo.FileUrl = _uploadedFileHandlerService.GetUploadedFileUrl(serverDirectory, photo.Name);

            var crudManager = _saveEntityService.ProcessSave(newDoc);
            if (input.From == "Field")
            {
                var field = _repository.Find<Field>(input.ParentId);
                field.AddPhoto(photo);
                crudManager = _saveEntityService.ProcessSave(field, crudManager);
            }
            crudManager = _uploadedFileHandlerService.SaveUploadedFile(serverDirectory, newDoc.Name, crudManager);

            var notification = crudManager.Finish();
            return Json(notification, "text/plain");
        }
Esempio n. 5
0
        private Photo mapToDomain(PhotoViewModel input, Photo photo)
        {
            var photoModel = input.Photo;
            photo.FileType = photoModel.FileType;

            photo.Name = photoModel.Name;
            photo.Description = photoModel.Description;
            if (photo.PhotoCategory == null || photo.PhotoCategory.EntityId != input.PhotoCategory)
            {
                photo.PhotoCategory = _repository.Find<PhotoCategory>(input.Photo.PhotoCategory.EntityId);
            }
            return photo;
        }