public async Task <IActionResult> Edit(int id, [Bind("UserId,Status,Id")] Publication publication) { if (id != publication.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(publication); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PublicationExists(publication.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["UserId"] = new SelectList(_context.Users, "Id", "Email", publication.UserId); return(View(publication)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,ProductId,Route")] Photo photo) { if (id != photo.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(photo); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PhotoExists(photo.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ProductId"] = new SelectList(_context.Products, "Id", "Id", photo.ProductId); return(View(photo)); }
public async Task <IActionResult> Edit(int id, [Bind("ExpireDate,Periodicity,RelatedCities,Id")] Alert alert) { if (id != alert.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(alert); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AlertExists(alert.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(alert)); }
public async Task <IActionResult> Edit(int id, [Bind("Description,ProductId,AlertId,Id")] Tag tag) { if (id != tag.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(tag); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TagExists(tag.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["AlertId"] = new SelectList(_context.Alerts, "Id", "Id", tag.AlertId); ViewData["ProductId"] = new SelectList(_context.Products, "Id", "Id", tag.ProductId); return(View(tag)); }
public async Task <IActionResult> Edit(int id, [Bind("FirstName,LastName,Email,Role,Country,IsActive,CityId,Id")] 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))); } ViewData["CityId"] = new SelectList(_context.Cities, "Id", "Name", user.CityId); return(View(user)); }
public async Task <IActionResult> Edit(int id, [Bind("Name,Id")] Category category) { if (id != category.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(category); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CategoryExists(category.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(category)); }
public async Task <IActionResult> Edit(int id, [Bind("CategoryId,Name,Id")] SubCategory subCategory) { if (id != subCategory.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(subCategory); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SubCategoryExists(subCategory.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Id", subCategory.CategoryId); return(View(subCategory)); }
public async Task <IActionResult> Edit(int id, [Bind("Date,Insignia,Status,Title,Description,Price,Units,CityId,PublicationId,SubCategoryId,Id")] Product product) { if (id != product.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(product); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(product.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CityId"] = new SelectList(_context.Cities, "Id", "Id", product.CityId); ViewData["PublicationId"] = new SelectList(_context.Set <Publication>(), "Id", "Id", product.PublicationId); ViewData["SubCategoryId"] = new SelectList(_context.SubCategories, "Id", "Id", product.SubCategoryId); return(View(product)); }
public async Task <IActionResult> Edit(int id, [Bind("Description,Status,ProductId,Id")] Question question) { if (id != question.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(question); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!QuestionExists(question.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ProductId"] = new SelectList(_context.Products, "Id", "Id", question.ProductId); return(View(question)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,SellerId,BuyerId,ProductId")] Transaction transaction) { if (id != transaction.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(transaction); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TransactionExists(transaction.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["BuyerId"] = new SelectList(_context.Users, "Id", "Email", transaction.BuyerId); ViewData["ProductId"] = new SelectList(_context.Products, "Id", "Id", transaction.ProductId); ViewData["SellerId"] = new SelectList(_context.Users, "Id", "Email", transaction.SellerId); return(View(transaction)); }
public async Task <IActionResult> Edit(int id, [Bind("UserId,Description,Interests,Facebook,Twitter,Instagram,Id")] Profile profile, IFormFile image) { if (id != profile.Id) { return(NotFound()); } if (ModelState.IsValid) { try { if (image != null && image.Length > 0) { var fileName = Path.Combine(_environment.WebRootPath, "avatars", image.FileName); await image.CopyToAsync(new FileStream(fileName, FileMode.Create)); profile.Avatar = "/avatars/" + image.FileName; } _context.Update(profile); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProfileExists(profile.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["UserId"] = new SelectList(_context.Users, "Id", "Email", profile.UserId); return(View(profile)); }