public async Task UpdateNationality([FromForm] NationalityRequest input) { bool checkName = await WorkScope.GetAll <Nationality>().AnyAsync(x => x.Name == input.Name && x.Id != input.Id); if (checkName) { throw new UserFriendlyException("Quốc tịch đã tồn tại"); } var nationality = await WorkScope.GetAll <Nationality>().FirstOrDefaultAsync(x => x.Id == input.Id); if (nationality == default) { throw new UserFriendlyException("Quốc tịch không tồn tại"); } nationality.Name = input.Name; if (input.Image?.Length > 0) { string fileLocation = UploadFiles.CreateFolderIfNotExists(ConstantVariable.RootFolder, $@"{ConstantVariable.UploadFolder}\{ConstantVariable.Company}"); string fileName = await UploadFiles.UploadAsync(fileLocation, input.Image); nationality.Path = $"{ConstantVariable.UploadFolder}/{ConstantVariable.Company}/{fileName}"; } await WorkScope.UpdateAsync(nationality); }
public async Task CreateNationalityAsync([FromForm] NationalityRequest input) { bool checkName = await WorkScope.GetAll <Nationality>().AnyAsync(x => x.Name == input.Name); if (checkName) { throw new UserFriendlyException("Quốc tịch đã tồn tại"); } string fileName = string.Empty; string fileLocation = UploadFiles.CreateFolderIfNotExists(ConstantVariable.RootFolder, $@"{ConstantVariable.UploadFolder}\{ConstantVariable.Nationality}"); if (input.Image?.Length > 0) { fileName = await UploadFiles.UploadAsync(fileLocation, input.Image); } var nationality = new Nationality { Name = input.Name, Path = $"{ConstantVariable.UploadFolder}/{ConstantVariable.Nationality}/{fileName}" }; await WorkScope.InsertAsync(nationality); }
public async Task ReadCVAsync(Guid id) { var cv = await WorkScope.GetAsync <CV>(id); cv.IsRead = true; await WorkScope.UpdateAsync(cv); }
public async Task <PagedResultDto <RecruitmentDto> > GetAllRecruitmentPagingAsync(RecruitmentPagingRequest input) { var user = await GetCurrentUserAsync(); var query = WorkScope.GetAll <CV>() .Where(x => x.PostId == input.PostId) .Include(x => x.Post) .WhereIf(user.UserType == UserType.Hr, x => x.Post.CreatorUserId == user.Id) .WhereIf(!input.SearchText.IsNullOrWhiteSpace(), x => x.Name.Contains(input.SearchText)) .WhereIf(input.StartDate.HasValue, x => x.CreationTime >= input.StartDate) .WhereIf(input.EndDate.HasValue, x => x.CreationTime < input.EndDate) .OrderByDescending(x => x.CreationTime) .Select(x => new RecruitmentDto { Id = x.Id, CreationTime = x.CreationTime, Email = x.Email, Link = x.Link, Name = x.Name, PhoneNumber = x.PhoneNumber, Portfolio = x.Portfolio, UserName = x.UserName, UserId = x.UserId, IsRead = x.IsRead, PostId = x.PostId }); int totalCount = await query.CountAsync(); var list = await query.PageBy((input.CurrentPage - 1) *input.PageSize, input.PageSize).ToListAsync(); return(new PagedResultDto <RecruitmentDto>(totalCount, list)); }
public async Task UpdateLesson(CreateLesson Input) { using (CurrentUnitOfWork.DisableFilter(AbpDataFilters.SoftDelete)) { if (CheckPerMissionCourse(AbpSession.UserId ?? 0, Input.Id)) { if (WorkScope.GetAll <Lesson>().Where(s => s.IsDeleted == false).Any(s => Input.CourseId == s.CourseId && s.Tilte.Contains(Input.Tilte))) { throw new UserFriendlyException("Khóa học đã tồn tại bài học này"); } else { var a = Input.MapTo <Lesson>(); a.CreatorUserId = AbpSession.UserId ?? 0; await WorkScope.UpdateAsync <Lesson>(a); //throw new UserFriendlyException("Thành công"); } } else { throw new UserFriendlyException("Bạn không có quyền"); } } }
public async Task <List <HardDiskDrive> > GetHardDiskDrives(int count = 10) { return(await WorkScope.GetAll <HardDiskDrive>() .OrderByDescending(x => x.CreationTime) .Take(count) .ToListAsync()); }
public async Task <List <ProductConfiguration> > GetProductConfigurations(int count = 10) { return(await WorkScope.GetAll <ProductConfiguration>() .OrderByDescending(x => x.CreationTime) .Take(count) .ToListAsync()); }
public async Task InsertOrUpdateCandidate(CandidateDto input) { var currentUser = await GetCurrentUserAsync(); if (!(await UserManager.IsInRoleAsync(currentUser, StaticRoleNames.Host.HR) || await UserManager.IsInRoleAsync(currentUser, StaticRoleNames.Host.Admin))) { throw new UserFriendlyException(ErrorCodes.Forbidden.AddOrEditCandidate); } if (input.Id != 0) { var interviewers = WorkScope.GetAll <InterviewCandidates>().Where(c => c.CvcandidateId == input.Id.Value); foreach (var inter in interviewers) { await WorkScope.GetRepo <InterviewCandidates, long>().DeleteAsync(inter); } var skills = WorkScope.GetAll <CVSkills>().Where(c => c.CvcandidateId == input.Id.Value); foreach (var skill in skills) { await WorkScope.GetRepo <CVSkills, long>().DeleteAsync(skill); } } var candidateId = await WorkScope.InsertOrUpdateAndGetIdAsync(ObjectMapper.Map <CVCandidates>(input)); if (input.Attachments != null && input.Attachments.Count > 0) { await InsertOrUpdateAttachments(input.Attachments, candidateId); } }
public async Task <List <VideoGraphicsArray> > GetVideoGraphicsArrays(int count = 10) { return(await WorkScope.GetAll <VideoGraphicsArray>() .OrderByDescending(x => x.CreationTime) .Take(count) .ToListAsync()); }
public async Task CreatePostAsync(PostRequest input) { var post = ObjectMapper.Map <Post>(input); var company = await WorkScope.GetAsync <Company>(input.CompanyId); int numberPostSameTitle = await WorkScope.GetAll <Post>() .Where(x => x.Title == input.Title && x.CompanyId == input.CompanyId) .CountAsync() + 1; post.PostUrl = $"{input.Title.RemoveSign4VietnameseString().ToIdentifier()}-{company.CompanyUrl}-{numberPostSameTitle}"; Guid id = await WorkScope.InsertAndGetIdAsync(post); foreach (var item in input.HashtagIds) { await WorkScope.InsertAsync(new CompanyPostHashtag { HashtagId = item, PostId = id }); } var request = new PostSitemap { Id = id, AgencyName = company.Name, IsCreate = true, PostUrl = post.PostUrl, Title = post.Title }; await SaveSiteMap(request); }
public async Task <PostDto> GetPostByIdAsync(Guid id) { var user = await GetCurrentUserAsync(); var post = await WorkScope.GetAll <Post>() .WhereIf(user.UserType == UserType.Hr, x => x.CreatorUserId == user.Id) .Include(x => x.CompanyPostHashtags) .Select(x => new PostDto { CompanyId = x.CompanyId, Content = x.Content, EndDate = x.EndDate, ExperienceType = x.ExperienceType, Id = x.Id, JobType = x.JobType, LevelId = x.LevelId, MaxMoney = x.MaxMoney, MinMoney = x.MinMoney, MoneyType = x.MoneyType, NumberOfViews = x.NumberOfViews, TimeExperience = x.TimeExperience, Title = x.Title, Hashtags = x.CompanyPostHashtags.Select(p => new HashtagCompanyPostModel { Id = p.Id, HashtagId = p.HashtagId, PostId = x.Id }).ToList() }).FirstOrDefaultAsync(x => x.Id == id); return(post); }
private async Task InsertOrUpdateAttachments(List <string> attachments, long candidateId) { if (attachments != null && attachments.Count > 0) { var typeAccept = Enum.GetValues(typeof(AttachmentTypeEnum)) .Cast <AttachmentTypeEnum>() .Select(v => v.ToString()) .ToList(); List <long> attachmentInserts = new List <long>(); foreach (var item in attachments) { var fileExtension = Path.GetExtension(item); if (fileExtension.ToLower() != ".png" && fileExtension.ToLower() != ".jpg") { throw new UserFriendlyException(ErrorCodes.NotAcceptable.FileNameExtensions); } attachmentInserts.Add(await WorkScope.InsertOrUpdateAndGetIdAsync(new CVAttachments { Path = item, Type = (AttachmentTypeEnum)Enum.Parse(typeof(AttachmentTypeEnum), fileExtension.Replace(".", "").ToUpper()), CvcandidateId = candidateId })); } await WorkScope.DeleteAsync <CVAttachments>(at => at.CvcandidateId == candidateId && !attachmentInserts.Contains(at.Id)); } }
public async Task <List <EducationDto> > GetEducationInfo(long userId) { if ((AbpSession.UserId.Value != userId) && !await UserManager.IsGrantedAsync(AbpSession.UserId.Value, PermissionNames.Pages_View_CVEmployee)) { throw new UserFriendlyException(ErrorCodes.Forbidden.AccessOtherProfile); } var lstEdu = new List <EducationDto>(); foreach (var edu in WorkScope.GetAll <Educations>().Where(e => e.CvemployeeId.Value == userId && e.IsDeleted == false).OrderBy(e => e.Order)) { var temp = new EducationDto { Id = edu.Id, SchoolOrCenterName = edu.SchoolOrCenterName, CvemployeeId = userId, DegreeType = edu.DegreeType, StartYear = edu.StartYear, EndYear = edu.EndYear, Description = edu.Description, Major = edu.Major, Order = edu.Order, }; lstEdu.Add(temp); } return(lstEdu); }
public async Task <List <WorkingExperienceDto> > GetWorkingExperiencePaging(string technologies) { if (technologies.IsNullOrEmpty()) { return(new List <WorkingExperienceDto>()); } var query = WorkScope.GetAll <EmployeeWorkingExperiences>().Where(u => !u.IsDeleted).Select( w => new WorkingExperienceDto { Id = w.Id, Position = w.Position, ProjectDescription = w.ProjectDescription, ProjectName = w.ProjectName, Responsibility = w.Responsibilities, EndTime = w.EndTime, StartTime = w.StartTime, UserId = w.UserId, Order = w.Order, Technologies = w.Technologies }).Where(u => u.Technologies.ToLower().Trim().Contains(technologies.ToLower().Trim())) .ToList(); return(query); }
private async Task SaveBranchJobAsync(BranchJobRequest input) { bool checkExists = await WorkScope.GetAll <BranchJob>().AnyAsync(x => x.Name == input.Name && x.Id != input.Id); if (checkExists) { throw new UserFriendlyException("Ngành nghề đã tồn tại"); } string branchJobUrl = input.Name.RemoveSign4VietnameseString().ToIdentifier(); if (input.Id.HasValue) { var branchJob = await WorkScope.GetAll <BranchJob>().FirstOrDefaultAsync(x => x.Id == input.Id); if (branchJob == default) { throw new UserFriendlyException("Ngành nghề không tồn tại"); } branchJob.Name = input.Name; branchJob.BranchJobUrl = branchJobUrl; await WorkScope.UpdateAsync(branchJob); } else { var hashtag = new BranchJob { Name = input.Name, BranchJobUrl = branchJobUrl }; await WorkScope.InsertAsync(hashtag); } }
public override async Task <ProjectDto> Save(ProjectDto req) { var result = await base.SaveReturnEntity(req); // save project member await WorkScope.Sync <BaseProjectMemberDto, ProjectMember>(req.ProjectMembers, x => x.ProjectId == result.Id, x => { x.ProjectId = result.Id; return(x); }); // save project customer await WorkScope.Sync <BaseProjectCustomerDto, ProjectCustomer>(req.ProjectCustomers, x => x.ProjectId == result.Id, x => { x.ProjectId = result.Id; return(x); }); // save project task await WorkScope.Sync <BaseProjectTaskDto, Entities.ProjectTask>(req.ProjectTasks, x => x.ProjectId == result.Id, x => { x.ProjectId = result.Id; return(x); }); var rs = ObjectMapper.Map <ProjectDto>(result); return(rs); }
public async Task <List <MainBroad> > GetMainBroads(int count = 10) { return(await WorkScope.GetAll <MainBroad>() .OrderByDescending(x => x.CreationTime) .Take(count) .ToListAsync()); }
public async Task UpdateTechnicalExpertise(TechnicalExpertiseDto input) { if (AbpSession.UserId != input.UserId) { throw new UserFriendlyException(ErrorCodes.Forbidden.EditOtherProfile); } var dbCVSkills = WorkScope.GetRepo <CVSkills, long>(); List <long> listCurrentId = new List <long>(); foreach (var grs in input.GroupSkills) { var cvSkills = grs.CVSkills; foreach (var s in cvSkills) { listCurrentId.Add(await dbCVSkills.InsertOrUpdateAndGetIdAsync(new CVSkills { CvemployeeId = input.UserId, GroupSkillId = grs.GroupSkillId, Id = s.Id ?? 0, Level = s.Level, SkillId = s.SkillId, SkillName = s.SkillName })); } } await dbCVSkills.DeleteAsync(c => !listCurrentId.Contains(c.Id) && c.CvemployeeId == input.UserId); }
private async Task SaveHashtagAsync(HashtagRequest input) { bool checkExists = await WorkScope.GetAll <Hashtag>().AnyAsync(x => x.Name == input.Name && x.Id != input.Id); if (checkExists) { throw new UserFriendlyException("Hashtag đã tồn tại"); } if (input.Id.HasValue) { var hashtag = await WorkScope.GetAll <Hashtag>().FirstOrDefaultAsync(x => x.Id == input.Id); if (hashtag == default) { throw new UserFriendlyException("Hashtag không tồn tại"); } hashtag.Name = input.Name; hashtag.IsHot = input.IsHot; hashtag.HashtagUrl = input.Name.RemoveSign4VietnameseString().ToIdentifier(); await WorkScope.UpdateAsync(hashtag); } else { var hashtag = new Hashtag { Name = input.Name, IsHot = input.IsHot, HashtagUrl = input.Name.RemoveSign4VietnameseString().ToIdentifier() }; await WorkScope.InsertAsync(hashtag); } }
private async Task SaveLevelAsync(LevelRequest input) { bool checkExists = await WorkScope.GetAll <Level>().AnyAsync(x => x.Name == input.Name && x.Id != input.Id); if (checkExists) { throw new UserFriendlyException("Level đã tồn tại"); } if (input.Id.HasValue) { var level = await WorkScope.GetAll <Level>().FirstOrDefaultAsync(x => x.Id == input.Id); if (level == default) { throw new UserFriendlyException("Level không tồn tại"); } level.Name = input.Name; await WorkScope.UpdateAsync(level); } else { var level = new Level { Name = input.Name }; await WorkScope.InsertAsync(level); } }
public async Task UpdatePersonalAttribute(PersonalAttributeDto input) { var user = await GetCurrentUserAsync(); user.PersonalAttribute = JsonConvert.SerializeObject(input.PersonalAttributes); await WorkScope.UpdateAsync(user); }
public async Task <TechnicalExpertiseDto> GetTechnicalExpertise(long userId) { if ((AbpSession.UserId.Value != userId) && !await UserManager.IsGrantedAsync(AbpSession.UserId.Value, PermissionNames.Pages_View_CVEmployee)) { throw new UserFriendlyException(ErrorCodes.Forbidden.AccessOtherProfile); } var query = await WorkScope.GetAll <User>() .Include(u => u.Cvskills) .ThenInclude(u => u.GroupSkill) .ThenInclude(cvs => cvs.Skills) .FirstOrDefaultAsync(u => u.Id == userId); var userGroupSkills = query.Cvskills.GroupBy(s => s.GroupSkillId) .Select(g => new GroupSkillAndSkillDto { GroupSkillId = g.Key.Value, Name = g.FirstOrDefault().GroupSkill.Name, CVSkills = g.Select(s => new CVSkillDto { Id = s.Id, SkillId = s.SkillId, SkillName = string.IsNullOrWhiteSpace(s.SkillName) ? s.GroupSkill.Skills.FirstOrDefault(sk => sk.Id == s.SkillId)?.Name : s.SkillName, Level = s.Level, }).ToList() }) .ToList(); return(new TechnicalExpertiseDto { UserId = userId, GroupSkills = userGroupSkills }); }
/* public async Task<PagedResultDto<GetAllCourseOutputDto>> GetAllCourseOfTeacher(GetAllCourseInput input) * { * var a = WorkScope.GetAll<Course>().WhereIf(!input.NameOfCourse.IsNullOrWhiteSpace(), s => s.Title.Contains(input.NameOfCourse)) * .Where(s => s.IsDeleted == false) * .WhereIf(input.UserID.HasValue, s => s.UserId == input.UserID) * .Select(s => new GetAllCourseOutputDto * { * Id = s.Id, * Creator = s.Creator.FullName, * DateCreator = s.CreationTime, * LastModify = s.LastModificationTime, * Tilte = s.Title, * Description = s.Details, * //TypeOfCourses=d.CourseType.Deltail.ToList() * }); * var TotalCount = await a.CountAsync(); * var result = await a.Skip(input.PageNumber - 1).Take(input.PageSize).ToListAsync(); * return new PagedResultDto<GetAllCourseOutputDto>(TotalCount, result); * }*/ public async Task <long> CreateCourse(CreateCourseInput input) { using (CurrentUnitOfWork.DisableFilter(AbpDataFilters.SoftDelete)) { if (IsTeacher() == true) { if (WorkScope.GetAll <Course>().Where(s => s.IsDeleted == false && (s.Title == input.Title || s.Code == input.Code)).Any()) { throw new UserFriendlyException("Đã tồn tại tên hoặc code khóa học"); } else { var a = input.MapTo <Course>(); a.UserId = AbpSession.UserId ?? 0; var id = await WorkScope.InsertAndGetIdAsync <Course>(a); return(id); } } else { throw new UserFriendlyException("Bạn không phải giáo viên, liên hệ admin để được hỗ trợ"); } } }
public async Task <List <WorkingExperienceDto> > GetUserWorkingExperience(long userId) { if ((AbpSession.UserId.Value != userId) && !await UserManager.IsGrantedAsync(AbpSession.UserId.Value, PermissionNames.Pages_View_CVEmployee)) { throw new UserFriendlyException(ErrorCodes.Forbidden.AccessOtherProfile); } return(await WorkScope.GetAll <EmployeeWorkingExperiences>() .Where(w => w.UserId == userId) .Select(w => new WorkingExperienceDto { Id = w.Id, Position = w.Position, ProjectDescription = w.ProjectDescription, ProjectName = w.ProjectName, Responsibility = w.Responsibilities, EndTime = w.EndTime, StartTime = w.StartTime, UserId = w.UserId, Order = w.Order, Technologies = w.Technologies }) .OrderBy(w => w.Order) .ToListAsync()); }
public async Task CreateCVAsync([FromForm] RecruitmentRequest input) { bool checkExist = await WorkScope.GetAll <CV>().AnyAsync(x => x.PostId == input.PostId && x.UserId == input.UserId && input.UserId.HasValue); if (checkExist) { throw new UserFriendlyException("Bạn đã ứng tuyển vị trí này"); } var post = await WorkScope.GetAsync <Post>(input.PostId); var cv = ObjectMapper.Map <CV>(input); if (input.FileCV?.Length > 0) { string fileLocation = UploadFiles.CreateFolderIfNotExists(ConstantVariable.RootFolder, $@"{ConstantVariable.UploadFolder}\{ConstantVariable.CV}\{post.PostUrl}"); string fileName = await UploadFiles.UploadAsync(fileLocation, input.FileCV); cv.Link = $"{ConstantVariable.UploadFolder}/{ConstantVariable.CV}/{post.PostUrl}/{fileName}"; } await WorkScope.InsertAsync(cv); }
public async Task <CompanyModel> GetCompanyByIdAsync(Guid id) { var user = await GetCurrentUserAsync(); var company = await WorkScope.GetAll <Company>() .Where(x => x.Id == id) .WhereIf(user.UserType == UserType.Hr, x => x.UserId == user.Id) .Include(x => x.CompanyPostHashtags) .Include(x => x.Assets) .Include(x => x.BranchJobCompanies) .Include(x => x.Nationality) .Select(x => new CompanyModel { Name = x.Name, Description = x.Description, FullNameCompany = x.FullNameCompany, Email = x.Email, Id = x.Id, Location = x.Location, LocationDescription = x.LocationDescription, MaxScale = x.MaxScale, MinScale = x.MinScale, NationalityCompany = x.Nationality.Name, Treatment = x.Treatment, Website = x.Website, Phone = x.Phone, IsHot = x.IsHot, Thumbnail = x.Assets.Where(p => p.FileType == FileType.Thumbnail && p.CompanyId == id).Select(p => new ObjectFile { FileType = p.FileType, Id = p.Id, Path = p.Path }).FirstOrDefault(), BranchJobCompanies = x.BranchJobCompanies.Select(p => new BranchJobCompanyModel { Id = p.Id, BranchJobId = p.BranchJobId }), Images = x.Assets.Where(p => p.FileType == FileType.Image && p.CompanyId == id).Select(p => new ObjectFile { FileType = p.FileType, Id = p.Id, Path = p.Path }), Hashtags = x.CompanyPostHashtags.Select(p => new HashtagCompanyPostModel { Id = p.Id, HashtagId = p.HashtagId }), NationalityId = x.NationalityId }).FirstOrDefaultAsync(); if (company == default) { throw new UserFriendlyException("Không tồn tại công ty"); } return(company); }
/// <summary> /// Prepare updates synchronously /// </summary> public void PrepareUpdates() { if (IsWorking) { throw new InvalidOperationException("Another update process is already in progress"); } using (WorkScope.New(isWorking => IsWorking = isWorking)) { lock (UpdatesToApply) { if (State != UpdateProcessState.Checked) { throw new InvalidOperationException("Invalid state when calling PrepareUpdates(): " + State); } if (UpdatesToApply.Count == 0) { throw new InvalidOperationException("No updates to prepare"); } if (!Directory.Exists(Config.TempFolder)) { Logger.Log("Creating Temp directory {0}", Config.TempFolder); Directory.CreateDirectory(Config.TempFolder); } else { Logger.Log("Using existing Temp directory {0}", Config.TempFolder); } foreach (var task in UpdatesToApply) { if (ShouldStop) { throw new UserAbortException(); } var t = task; task.ProgressDelegate += status => TaskProgressCallback(status, t); try { task.Prepare(UpdateSource); } catch (Exception ex) { task.ExecutionStatus = TaskExecutionStatus.FailedToPrepare; Logger.Log(ex); throw new UpdateProcessFailedException("Failed to prepare task: " + task.Description, ex); } task.ExecutionStatus = TaskExecutionStatus.Prepared; } State = UpdateProcessState.Prepared; } } }
public async Task DeleteLesson(long LessonId) { using (CurrentUnitOfWork.DisableFilter(AbpDataFilters.SoftDelete)) { var a = WorkScope.GetAll <Lesson>().Where(s => s.Id == LessonId).Select(s => s).FirstOrDefault(); WorkScope.SoftDeleteAsync <Lesson>(a); } }
public async Task UpdateWorkingExperience(WorkingExperienceDto input) { if (AbpSession.UserId != input.UserId) { throw new UserFriendlyException(ErrorCodes.Forbidden.EditOtherProfile); } await WorkScope.InsertOrUpdateAndGetIdAsync(ObjectMapper.Map <EmployeeWorkingExperiences>(input)); }
public async Task DeleteCandidate(long candidateId) { var skills = WorkScope.GetAll <CVSkills>().Where(c => c.CvcandidateId == candidateId); foreach (var skill in skills) { await WorkScope.GetRepo <CVSkills, long>().DeleteAsync(skill); } var candidate = await WorkScope.GetAll <CVCandidates>().FirstOrDefaultAsync(c => c.Id == candidateId); if (candidate == default) { throw new UserFriendlyException(ErrorCodes.NotFound.Candidate); } var pathRoot = _hostingEnvironment.WebRootPath; if (candidate.AttachmentPatch != null) { var docPath = Path.Combine(pathRoot, candidate.AttachmentPatch.Replace("/", @"\")); if (File.Exists(docPath)) { File.Delete(docPath); } } await WorkScope.Repository <CVCandidates>().DeleteAsync(candidate); var attachments = WorkScope.GetAll <CVAttachments>().Where(c => c.CvcandidateId == candidateId); foreach (var att in attachments) { await WorkScope.GetRepo <CVAttachments, long>().DeleteAsync(att); } var interviewers = WorkScope.GetAll <InterviewCandidates>().Where(c => c.CvcandidateId == candidateId); foreach (var inter in interviewers) { await WorkScope.GetRepo <InterviewCandidates, long>().DeleteAsync(inter); } foreach (var att in attachments) { var file = Path.Combine(pathRoot, att.Path.Replace("/", @"\")); if (File.Exists(file)) { File.Delete(file); } else { continue; } } }