public async Task <bool> DeleteImage(int specialistId) { var specialist = await context.Specialists.FindAsync(specialistId); if (!string.IsNullOrWhiteSpace(specialist.ImageUrl)) { FileUploadHelper.Delete(specialist.ImageUrl); } specialist.ImageUrl = string.Empty; context.Specialists.Update(specialist); return(await context.SaveChangesAsync() > 0); }
public async Task <bool> DeleteWork(int workId) { if (workId <= 0) { return(false); } var specialistWork = await context.SpecialistWorks.FindAsync(workId); FileUploadHelper.Delete(specialistWork.ImagePath); context.SpecialistWorks.Remove(specialistWork); return(await context.SaveChangesAsync() > 0); }
public IResult DeleteImage(CarImage imageq) { var image = _carImageDal.Get(c => c.Id == imageq.Id); if (image == null) { return(new ErrorResult("Image not found")); } FileUploadHelper.Delete(image.ImagePath); _carImageDal.Delete(image); return(new SuccessResult(Messages.ImageDeleted)); }
public IResult Delete(CarImage carImage) { var image = _carImageDal.Get(c => c.ImageId == carImage.ImageId); if (image == null) { return(new ErrorResult("Image not found")); } FileUploadHelper.Delete(image.ImagePath); _carImageDal.Delete(carImage); return(new SuccessResult("Image was deleted successfully")); }
public async Task <bool> UpdatePasport(int specialistId, IFormFile image) { var newPasportPath = await FileUploadHelper.UploadAsync(image, ImageOwnerEnum.Specialist); if (newPasportPath == string.Empty) { return(false); } var specialist = await context.Specialists.FindAsync(specialistId); if (!string.IsNullOrWhiteSpace(specialist.PassportPath)) { FileUploadHelper.Delete(specialist.PassportPath); } specialist.PassportPath = newPasportPath; return(await context.SaveChangesAsync() > 0); }
public async Task <IActionResult> DeletePortrait() { var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); var specialist = await _specialistService.FindAsync(userId); FileUploadHelper.Delete(specialist.ImageUrl); specialist.ImageUrl = ""; Response.Cookies.Append("profileImage", ""); await _specialistService.UpdateAsync(specialist); if (!specialist.ImageUrl.IsNullOrWhiteSpace()) { TempData["Status"] = "Photo did not upload"; } else { TempData["Status"] = "Photo sent successfully"; } return(View("UploadPortrait")); }