public async Task <IActionResult> Edit(int?id, [Bind("Id,Mark,AdvertisementId,UserId")] AdvMark advMark) { if (id != advMark.AdvertisementId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(advMark); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AdvMarkExists(advMark.AdvertisementId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["AdvertisementId"] = new SelectList(_context.Advertisements, "AdvertisementId", "Company", advMark.AdvertisementId); ViewData["UserId"] = new SelectList(_context.Users, "Id", "Email", advMark.UserId); return(View(advMark)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Email,Password,RoleId")] 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["RoleId"] = new SelectList(_context.Roles, "Id", "Id", user.RoleId); return(View(user)); }
public async Task <IActionResult> Edit(int id, [Bind("AdvertisementId,Company,Text")] Advertisement advertisement) { if (id != advertisement.AdvertisementId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(advertisement); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AdvertisementExists(advertisement.AdvertisementId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(advertisement)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Effort,kef,Profit,AdvertisementId")] ProfitAdv profitAdv) { if (id != profitAdv.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(profitAdv); if (profitAdv.Effort > 0 && profitAdv.Effort <= 4000) { profitAdv.kef = 2; } else if (profitAdv.Effort > 4000 && profitAdv.Effort <= 10000) { profitAdv.kef = 5; } else if (profitAdv.Effort > 10000 && profitAdv.Effort <= 50000) { profitAdv.kef = 11; } else { profitAdv.kef = 18; } profitAdv.Profit = (int)(profitAdv.Effort + (profitAdv.kef * profitAdv.Effort / 9)); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProfitAdvExists(profitAdv.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["AdvertisementId"] = new SelectList(_context.Advertisements, "AdvertisementId", "Company", profitAdv.AdvertisementId); return(View(profitAdv)); }