public ActionResult EditFileType(FileTypeViewModel model) { if (IsModelValidAndPersistErrors()) { FileType fileType = _fileTypeRepository.Get(model.FileTypeID); UpdateModel(fileType); _fileTypeRepository.Update(fileType); SetSuccess("File type edited"); return(RedirectToAction("FileTypes")); } return(RedirectToSelf()); }
public ActionResult FileTypes() { IEnumerable <FileType> fileTypes = _fileTypeRepository.Get(); List <FileInfo> fileTypeImages = _fileTypeServices.GetFileTypeImages(); FileTypeViewModel model = new FileTypeViewModel() { FileTypes = fileTypes, Images = fileTypeImages.Select(item => item.Name).ToList() }; return(View(model)); }
public ActionResult EditFileType(int FileTypeID) { List <FileInfo> fileTypeImages = _fileTypeServices.GetFileTypeImages(); FileType fileType = _fileTypeRepository.Get(FileTypeID); FileTypeViewModel model = new FileTypeViewModel() { Extension = fileType.Extension, Image = fileType.Image, FileTypeID = fileType.FileTypeID, Images = fileTypeImages.Select(item => item.Name).ToList() }; return(View(model)); }
public ActionResult FileTypes(FileTypeViewModel model) { if (IsModelValidAndPersistErrors()) { FileType fileType = new FileType() { Extension = model.Extension, Image = model.Image }; _fileTypeRepository.Add(fileType); SetSuccess("File type created"); } return(RedirectToSelf()); }
public static FileType MapToFileType(FileTypeViewModel fileTypeViewModel) { if (fileTypeViewModel != null) { return(new FileType() { Id = fileTypeViewModel.Id, TypeName = fileTypeViewModel.TypeName, IsChecked = fileTypeViewModel.IsChecked }); } else { return(null); } }