private void DeletePoster(List <PosterImageEntity> posters) { foreach (var item in posters ?? new List <PosterImageEntity>()) { posterSrv.Delete(item); DirectoryTools.DeleteFile(HttpContext.Server.MapPath, item.MaxImage); DirectoryTools.DeleteFile(HttpContext.Server.MapPath, item.MinImage); } }
public string UploadAvatar() { HttpPostedFileBase file = Request.Files["Avatar"]; DirectoryTools.CheckDirectoryExist(AppConstants.directoryProfileAvatar); string ownerId = User.Identity.GetUserId(); var path = ImageResize.Resize(file, AppConstants.directoryProfileAvatar, 135, 135); var smallPath = ImageResize.Resize(file, AppConstants.directoryProfileAvatar, 40, 40); if (UserManager.IsInRole(ownerId, RoleConstant.RoleCompany)) { var company = orgSrv.GetById(GetCurrentUser().Id); if (company != null) { if (!string.IsNullOrEmpty(company.LargePathImage)) { DirectoryTools.DeleteFile(HttpContext, company.LargePathImage, AppConstants.directoryProfileAvatar); } if (!string.IsNullOrEmpty(company.SmallPathImage)) { DirectoryTools.DeleteFile(HttpContext, company.SmallPathImage, AppConstants.directoryProfileAvatar); } company.LargePathImage = path; company.SmallPathImage = smallPath; orgSrv.Edit(company); } } else { var userPicture = userSrv.Get(GetCurrentUser().Id); if (!string.IsNullOrEmpty(userPicture.PicturePath)) { DirectoryTools.DeleteFile(HttpContext, userPicture.PicturePath, AppConstants.directoryProfileAvatar); } userSrv.UploadAvatar(path, GetCurrentUser()); } return(AppConstants.directoryProfileAvatar + path); }
private void DeletePreviewPictures(IEnumerable <PreviewPictures> pics, int articleId) { if (pics != null && pics.Count() > 0) { foreach (var pic in pics) { if (pic.LargeSizePath != null) { DirectoryTools.DeleteFile(HttpContext, pic.LargeSizePath, AppConstants.dirNewsPreview); } if (pic.SmallSizePath != null) { DirectoryTools.DeleteFile(HttpContext, pic.SmallSizePath, AppConstants.dirNewsPreview); } } newsSrv.RemovePicture(articleId, null); } }
public ActionResult DeletePicture(int picId, int articleId) { var pic = newsSrv.GetPicture(picId); if (pic != null) { if (pic.LargeSizePath != null) { DirectoryTools.DeleteFile(HttpContext, pic.LargeSizePath); } if (pic.SmallSizePath != null) { DirectoryTools.DeleteFile(HttpContext, pic.SmallSizePath); } newsSrv.RemovePicture(picId); } return(RedirectToAction("Edit", new { id = articleId })); }
public ActionResult Edit(OrganizationViewModel model) { model.IsInRole = User.IsInRole; if (ModelState.IsValid) { if (model.ImgFile != null) { DirectoryTools.CheckDirectoryExist(AppConstants.directoryProfileAvatar); var entity = orgService.GetById(model.Id); if (entity != null) { if (entity.SmallPathImage != null) { DirectoryTools.DeleteFile(HttpContext, entity.SmallPathImage); } if (entity.LargePathImage != null) { DirectoryTools.DeleteFile(HttpContext, entity.LargePathImage); } } model.SmallPathImage = ImageResize.Resize(model.ImgFile, AppConstants.directoryProfileAvatar, 50, 50); model.LargePathImage = ImageResize.Resize(model.ImgFile, AppConstants.directoryProfileAvatar, 250, 250); } var result = orgService.Edit(OrganizationMapper.ToEntity(model)); if (result != null) { return(RedirectToAction("Index", "Organization")); } } ViewBag.ListСlassifikate = new SelectList(classifierService.GetAll.ToList(), "Id", "Name"); return(View(model)); }