public async Task <IActionResult> EditPhoto(PhotoEditViewModel model) { if (ModelState.IsValid) { var photo = new Photo { Id = model.Id, Name = model.Name, Description = model.Description, Category = model.Category, FaceBookLink = model.FacebookLink, InstagramLink = model.InstagramLink, TwitterLink = model.TwitterLink }; if (model.Image == null) { photo.PhotoUrl = model.PhotoUrl; } else { if (!String.IsNullOrWhiteSpace(model.PhotoUrl)) { _fileManager.RemoveImage(model.PhotoUrl); } photo.PhotoUrl = _fileManager.SaveImage(model.Image); } await _photoRepo.UpdatePhoto(photo); if (await _photoRepo.SaveChangesAsync()) { return(RedirectToAction(nameof(Index))); } _clientNotification.AddToastNotification("Could not Update Photo Item", NotificationHelper.NotificationType.error, new ToastNotificationOption { NewestOnTop = true, CloseButton = true, PositionClass = "toast-top-right", PreventDuplicates = true }); return(View(model)); } _clientNotification.AddToastNotification("You Have Errors", NotificationHelper.NotificationType.error, new ToastNotificationOption { NewestOnTop = true, CloseButton = true, PositionClass = "toast-top-right", PreventDuplicates = true }); return(View(model)); }
public ActionResult UpdateAccount(ProfileModels model) { string identificateur = User.Identity.GetUserId(); if (model.Image != null) { MemoryStream target = new MemoryStream(); model.Image.InputStream.CopyTo(target); photo = new Photo(); photo.UpdatePhoto(identificateur, target.ToArray()); } var user = UserManager.FindById(identificateur); user.Email = model.Email; user.PhoneNumber = model.PhoneNumber; UserManager.Update(user); return RedirectToAction("MonProfil", "Account"); }