public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] 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("Id,Name,LogoUrl,ImageUrl,Location,WorkingHours,TelephoneNumber,Email,Description,SubCategoryId")] Shop shop) { if (id != shop.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(shop); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ShopExists(shop.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Details), new { id = shop.Id })); } ViewData["SubCategoryId"] = new SelectList(_context.Subcategory, "Id", "Name", shop.SubCategoryId); return(View(shop)); }
public async Task <IActionResult> Edit(int id, Employee employee, IFormFile cvUrl) { if (id != employee.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(employee); employee.CVUrl = UploadFile(cvUrl); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeeExists(employee.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(employee)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,CategoryId")] 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.Category, "Id", "Name", subcategory.CategoryId); return(View(subcategory)); }
public async Task <IActionResult> Edit(int id, Employment entry) { if (id != entry.Id) { return(NotFound()); } var employment = _context.Employment.FirstOrDefault(s => s.Id == id); if (ModelState.IsValid) { try { employment.FinishDate = entry.FinishDate; _context.Update(employment); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmploymentExists(employment.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["EmployeeId"] = new SelectList(_context.Employee, "Id", "FullName", employment.EmployeeId); ViewData["ShopId"] = new SelectList(_context.Shop, "Id", "Name", employment.ShopId); return(View(employment)); }
public async Task <IActionResult> Edit(int id, Employment entry) { if (id != entry.Id) { return(NotFound()); } var employment = _context.Employment.FirstOrDefault(s => s.Id == id); if (employment == null) { return(NotFound()); } AppUser user = await userManager.GetUserAsync(User); if (employment.EmployeeId != user.EmployeeId) { return(RedirectToAction("AccessDenied", "Account", null)); } if (ModelState.IsValid) { try { employment.Comment = entry.Comment; _context.Update(employment); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmploymentExists(employment.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(MyEmployments), new { id = employment.EmployeeId })); } ViewData["ShopId"] = new SelectList(_context.Shop, "Id", "Name", employment.ShopId); return(View(employment)); }