public async Task <IActionResult> Edit(int id, [Bind("CommentId,AnimalId,UserId,Commentary")] AnimalComment animalComment) { if (id != animalComment.CommentId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(animalComment); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AnimalCommentExists(animalComment.CommentId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(animalComment)); }
public async Task <IActionResult> Edit(int id, [Bind("Email,PasswordHash,Name,Birthday,PhoneNumber,Id,UserName,NormalizedUserName,NormalizedEmail,EmailConfirmed,SecurityStamp,ConcurrencyStamp,PhoneNumberConfirmed,TwoFactorEnabled,LockoutEnd,LockoutEnabled,AccessFailedCount")] User user) { if (id != user.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(user); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserExists(user.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(user)); }
public async Task <IActionResult> Edit(int id, [Bind("LogId,LogType,LogValue,LogDate")] Log log) { if (id != log.LogId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(log); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LogExists(log.LogId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(log)); }
public async Task <IActionResult> Edit(int id, [Bind("UserNotificationId,NotificationDate,HasRead,Title,Message,UserId")] UserNotification userNotification) { if (id != userNotification.UserNotificationId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(userNotification); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserNotificationExists(userNotification.UserNotificationId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(userNotification)); }
public async Task <IActionResult> Edit(int id, [Bind("AnimalId,Name,Weight,Height,Details")] Animal animal, [Bind(Prefix = "Animal.Image")] IFormFile image) { if (id != animal.AnimalId) { return(NotFound()); } var curAnimal = await _context.Animals.FindAsync(id); curAnimal.Name = animal.Name; curAnimal.Weight = animal.Weight; curAnimal.Height = animal.Height; curAnimal.Details = animal.Details; try { if (image != null) { using (var memoryStream = new MemoryStream()) { await image.CopyToAsync(memoryStream); memoryStream.Position = 0; Account account = new Account("adotaqui", "763436643874459", "G8jgeFUttCwjs-y-aJ0vjzLkUOA"); Cloudinary cloudinary = new Cloudinary(account); Random random = new Random(); var uploadParams = new ImageUploadParams() { Folder = "adotaqui", File = new FileDescription(random.Next(10000000, 99999999).ToString(), memoryStream) }; var uploadResult = cloudinary.Upload(uploadParams); curAnimal.Image = uploadResult.SecureUri.ToString(); } } _context.Update(curAnimal); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { } return(await Edit(id)); }