public async Task <IActionResult> PutAlarmy(int id, Alarmy alarmy) { if (id != alarmy.Id) { return(BadRequest()); } _context.Entry(alarmy).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AlarmyExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Create([Bind("Id,Title,Employer,ReleaseDate,About,Level,Level2,UseId")] Alarmy alarmy) { switch (alarmy.Level) { case 1: alarmy.Level2 = "Niski"; break; case 2: alarmy.Level2 = "Ĺredni"; break; case 3: if (User.IsInRole("Emp3")) { alarmy.Level2 = "Wysoki"; } else { return(RedirectToAction(nameof(No))); } break; } string Userid = User.Identity.Name; alarmy.UseId = Userid; if (ModelState.IsValid) { _context.Add(alarmy); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(alarmy)); }