public async Task <IActionResult> Put([FromRoute] int id, [FromRoute] string nmrid, [FromBody] TblOtptfu item) { if (!TryValidateModel(item)) { return(BadRequest()); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != item.Otptfuid) { return(BadRequest()); } Nmr nmr = await _context.Nmr.SingleOrDefaultAsync(m => m.Nmrid == item.Nmrid); if (nmr == null) { return(NotFound()); } if (nmr.StatusId == 3 || nmr.HfactiveStatusId != 1) { return(BadRequest()); } if (User.Identity.Name == nmr.UserName) { nmr.UpdateDate = DateTime.Now; nmr.StatusId = 2; _context.Entry(item).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!Exists(id, nmrid)) { return(NotFound()); } else { throw; } } return(NoContent()); } else { return(Unauthorized()); } }
public async Task <IActionResult> Create([Bind("Id,Name")] Tenant item) { if (ModelState.IsValid) { _context.Attach(item); _context.Entry(item).State = EntityState.Added; await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(item)); }
public async Task <IActionResult> Put([FromRoute] int id, [FromRoute] string nmrid, [FromBody] TblMn item) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != item.Mnid || nmrid != item.Nmrid) { return(BadRequest()); } var user = User.Identity.Name; var update = DateTime.Now; var report = _context.Nmr.SingleOrDefault(m => m.Nmrid == nmrid); if (report == null) { return(BadRequest()); } if (report.StatusId == 3 || report.HfactiveStatusId != 1) { return(BadRequest()); } if (report.UserName != user) { return(Unauthorized()); } report.UpdateDate = update; report.StatusId = 2; _context.Entry(item).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!Exists(id, nmrid)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Put([FromRoute] int id, [FromRoute] string nmrid, [FromBody] TblOtp model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != model.Otpid) { return(BadRequest()); } if (model.UserName != User.Identity.Name) { return(Unauthorized()); } var nmr = await _context.Nmr.SingleOrDefaultAsync(m => m.Nmrid == nmrid); if (!authorizeAction(nmr)) { return(BadRequest()); } nmr.UpdateDate = DateTime.Now; nmr.StatusId = 2; _context.Entry(model).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!Exists(id, nmrid)) { return(NotFound()); } else { throw; } } return(NoContent()); }