public async Task<IActionResult> Edit(AboutMeUpdateDto aboutMeUpdateDto, IFormFile fileImage, IFormFile fileCV) { if (ModelState.IsValid) { if (fileImage != null) { string imgExtension = Path.GetExtension(fileImage.FileName); string imgName = Guid.NewGuid() + imgExtension; string imgPath = Path.Combine(Directory.GetCurrentDirectory(), $"wwwroot/uploads/img/{imgName}"); using var streamImg = new FileStream(imgPath, FileMode.Create); await fileImage.CopyToAsync(streamImg); aboutMeUpdateDto.ImagePath = $"/uploads/img/{imgName}"; } if (fileCV != null) { string cvExtension = Path.GetExtension(fileCV.FileName); string cvName = Guid.NewGuid() + cvExtension; string cvPath = Path.Combine(Directory.GetCurrentDirectory(), $"wwwroot/uploads/cv/{cvName}"); using var streamCV = new FileStream(cvPath, FileMode.Create); await fileCV.CopyToAsync(streamCV); aboutMeUpdateDto.MyCVPath = $"/uploads/cv/{cvName}"; } await _aboutMeService.Update(aboutMeUpdateDto, "Hasan Erdal"); return RedirectToAction("Index"); } return View(aboutMeUpdateDto); }
public async Task <IDataResult <AboutMeDto> > Update(AboutMeUpdateDto aboutMeUpdateDto) { if (aboutMeUpdateDto != null) { var about = _mapper.Map <AboutMe>(aboutMeUpdateDto); await _unitOfWork.AboutMe.UpdateAsync(about); await _unitOfWork.SaveAsync(); return(new DataResult <AboutMeDto>(ResultStatus.Success, new AboutMeDto { AboutMe = about })); } return(new DataResult <AboutMeDto>(ResultStatus.Error, "Hata. Girdiğiniz bilgileri kontrol ediniz.", null)); }
public async Task <IDataResult <AboutMeDto> > Update(AboutMeUpdateDto aboutMeUpdateDto, string modifiedByName) { var aboutMe = _mapper.Map <AboutMe>(aboutMeUpdateDto); aboutMe.ModifiedByName = modifiedByName; var updatedAboutMe = await _unitOfWork.AboutMe.UpdateAsync(aboutMe); await _unitOfWork.SaveAsync(); return(new DataResult <AboutMeDto>(ResultStatus.Success, "Hakkımda bilgisi başarıyla güncellenmiştir.", new AboutMeDto { ResultStatus = ResultStatus.Success, AboutMe = updatedAboutMe, Message = "Hakkımda bilgisi başarıyla güncellenmiştir." })); }