public async Task <IActionResult> Edit( long?id, string referer, string sortOrder, string searchString, int?page, int?pageSize, [Bind("Id,UserName,Password")] JwtUser item, string currentFilter = "") { // pass page configuration to Views ViewData["CurrentSort"] = sortOrder; ViewData["sortOrder"] = sortOrder; ViewData["searchString"] = searchString; ViewData["page"] = page; ViewData["pageSize"] = pageSize; ViewData["currentFilter"] = currentFilter; if (id != item.Id) { return(NotFound()); } var oldItem = _context.JwtUsers.AsNoTracking().SingleOrDefault(m => m.Id == id); if (oldItem == null) { return(NotFound()); } if (item.Password != null && !item.Password.Equals(oldItem.Password)) { item.Password = _tokenizer.GetSHA1HashData(item.Password); } if (ModelState.IsValid) { try { _context.Update(item); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!JwtUserExists(item.Id)) { return(NotFound()); } else { throw; } } if (referer == null) { return(RedirectToAction("Index")); } return(new RedirectResult(referer)); } return(View(item)); }
public async Task <IActionResult> Edit( long?id, long?contributorId, long?paperId, string referer, string sortOrder, string searchString, int?page, int?pageSize, [Bind("Id,Name,Description,Content,ContributorId,PaperId,Comments,AuditEntered,AuditEnteredBy,AuditUpdated,AuditUpdatedBy")] PaperVersion item, string currentFilter = "") { // pass page configuration to Views ViewData["CurrentSort"] = sortOrder; ViewData["sortOrder"] = sortOrder; ViewData["searchString"] = searchString; ViewData["page"] = page; ViewData["pageSize"] = pageSize; ViewData["currentFilter"] = currentFilter; ViewData["contributorId"] = contributorId; ViewData["paperId"] = paperId; if (id != item.Id) { return(NotFound()); } var oldItem = _context.PaperVersions.AsNoTracking().SingleOrDefault(m => m.Id == id); if (oldItem == null) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(item); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PaperVersionExists(item.Id)) { return(NotFound()); } else { throw; } } if (referer == null) { return(RedirectToAction("Index")); } return(new RedirectResult(referer)); } return(View(item)); }
public async Task <IActionResult> Edit( long?id, string referer, string sortOrder, string searchString, int?page, int?pageSize, [Bind("Id,Name,Description,MyBoolean,MyCreditCard,MyCurrency,MyDateTime,MyDouble,MyEmail,MyFloat,MyImageUrl,MyInteger,MyLong,MyPhone,MyPostalCode,MyString,MyTextArea,MyTicks,MyUrl,Comments,AuditEntered,AuditEnteredBy,AuditUpdated,AuditUpdatedBy")] TestField item, string currentFilter = "") { // pass page configuration to Views ViewData["CurrentSort"] = sortOrder; ViewData["sortOrder"] = sortOrder; ViewData["searchString"] = searchString; ViewData["page"] = page; ViewData["pageSize"] = pageSize; ViewData["currentFilter"] = currentFilter; if (id != item.Id) { return(NotFound()); } var oldItem = _context.TestFields.AsNoTracking().SingleOrDefault(m => m.Id == id); if (oldItem == null) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(item); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TestFieldExists(item.Id)) { return(NotFound()); } else { throw; } } if (referer == null) { return(RedirectToAction("Index")); } return(new RedirectResult(referer)); } return(View(item)); }
public async Task Add(CourseInstance courseInstance) { _context.CourseInstances.Add(courseInstance); await _context.SaveChangesAsync(); }
public async Task <IActionResult> Edit( long?id, string state, string sortOrder, string searchString, int?page, int?pageSize, [Bind("Id,Name,Description,Degree,AlmaMater,Email,Evaluations,Password,Comments,AuditEntered,AuditEnteredBy,AuditUpdated,AuditUpdatedBy")] Contributor item, string currentFilter = "") { // Manage call stack var stack = new ServiceStack(state); var referer = stack.GetReturnUrl(); var callstack = state; // pass page configuration to Views ViewData["referer"] = referer; ViewData["callstack"] = callstack; // pass page configuration to Views ViewData["CurrentSort"] = sortOrder; ViewData["sortOrder"] = sortOrder; ViewData["searchString"] = searchString; ViewData["page"] = page; ViewData["pageSize"] = pageSize; ViewData["currentFilter"] = currentFilter; if (id != item.Id) { return(NotFound()); } var oldItem = _context.Contributors.AsNoTracking().SingleOrDefault(m => m.Id == id); if (oldItem == null) { return(NotFound()); } if (item.Password != null && !item.Password.Equals(oldItem.Password)) { item.Password = _tokenizer.GetSHA1HashData(item.Password); } if (ModelState.IsValid) { try { _context.Update(item); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ContributorExists(item.Id)) { return(NotFound()); } else { throw; } } if (referer == null) { return(RedirectToAction("Index")); } return(new RedirectResult(referer)); } return(View(item)); }