private ValidationResultDTO ValidateFileFolder(FileFolderEntity fileFolder, bool isNewTemplate) { var validationResult = new ValidationResultDTO { Success = true }; if (string.IsNullOrEmpty(fileFolder.Name)) { validationResult.Success = false; validationResult.ErrorMessage = "Name Is Not Valid"; return(validationResult); } if (fileFolder.Path.Trim().EndsWith("/") || fileFolder.Path.Trim().EndsWith(@"\")) { char[] toRemove = { '/', '\\' }; var trimmed = fileFolder.Path.TrimEnd(toRemove); fileFolder.Path = trimmed; } if (fileFolder.Path.Trim().StartsWith("/") || fileFolder.Path.Trim().StartsWith(@"\")) { char[] toRemove = { '/', '\\' }; var trimmed = fileFolder.Path.TrimStart(toRemove); fileFolder.Path = trimmed; } fileFolder.Path = StringManipulationServices.WindowsToUnixFilePath(fileFolder.Path); if (isNewTemplate) { if (_uow.FileFolderRepository.Exists(h => h.Name == fileFolder.Name)) { validationResult.Success = false; validationResult.ErrorMessage = "File / Folder Name Already Exists"; return(validationResult); } } else { var originalTemplate = _uow.FileFolderRepository.GetById(fileFolder.Id); if (originalTemplate.Name != fileFolder.Name) { if (_uow.FileFolderRepository.Exists(h => h.Name == fileFolder.Name)) { validationResult.Success = false; validationResult.ErrorMessage = "File / Folder Already Exists"; return(validationResult); } } } return(validationResult); }
public ActionResultDTO AddImageProfileFileFolder(ImageProfileFileFolderEntity imageProfileFileFolder) { imageProfileFileFolder.DestinationFolder = StringManipulationServices.WindowsToUnixFilePath(imageProfileFileFolder.DestinationFolder); if (imageProfileFileFolder.DestinationFolder.Trim().EndsWith("/") && imageProfileFileFolder.DestinationFolder.Length > 1) { char[] toRemove = { '/' }; var trimmed = imageProfileFileFolder.DestinationFolder.TrimEnd(toRemove); imageProfileFileFolder.DestinationFolder = trimmed; } _uow.ImageProfileFileFolderRepository.Insert(imageProfileFileFolder); _uow.Save(); var actionResult = new ActionResultDTO(); actionResult.Success = true; actionResult.Id = imageProfileFileFolder.Id; return(actionResult); }