public async Task <int> UpdateByAsync(TEntity obj) { //_dbContext.Entry(obj).CurrentValues.SetValues(obj); //var entity = _dbContext.Entry(obj); //entity.State = EntityState.Unchanged; _dbContext.Update(obj); return(await _dbContext.SaveChangesAsync()); }
public async Task <IActionResult> Edit(int id, [Bind("themeId,themeName,backgroundColor,fontStyle")] Theme theme) { if (id != theme.themeId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(theme); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ThemeExists(theme.themeId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(theme)); }
public async Task <IActionResult> Edit(string id, [Bind("studentAdmin,studentName,projectId,studentYear,dateCreated")] Student student) { if (id != student.studentAdmin) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(student); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StudentExists(student.studentAdmin)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(student)); }
public async Task <IActionResult> Edit(int id, [Bind("awardId,awardName,awardLevel,noOfRecipients,awardType,dateCreated")] Awards awards) { if (id != awards.awardId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(awards); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AwardsExists(awards.awardId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(awards)); }
public async Task <IActionResult> Edit(int id, [Bind("visitId,companyName,companyTypeId,noOfPax,visitDate,visitTypeId,dateCreated")] Visits visits) { if (id != visits.visitId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(visits); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VisitsExists(visits.visitId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(visits)); }
public async Task <IActionResult> Edit(int id, [Bind("courseId,courseName,courseSubject,courseInstructor,courseVenue,dateCreated")] ShortCourses shortCourses) { if (id != shortCourses.courseId) { return(NotFound()); } if (ModelState.IsValid) { try { // var list = await _context.ShortCourses.SingleOrDefaultAsync(m => m.courseId == id); //shortCourses.dateCreated = list.dateCreated; _context.Update(shortCourses); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ShortCoursesExists(shortCourses.courseId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(shortCourses)); }
public async Task <IActionResult> Edit(int id, [Bind("visitTypeId,visitType")] VisitType visitType1) { if (id != visitType1.visitTypeId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(visitType1); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VisitTypeExists(visitType1.visitTypeId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(visitType1)); }
public async Task <IActionResult> Edit(int id, [Bind("projectId,projectName,projectState,noOfStudents,dateCreated")] Projects projects) { if (id != projects.projectId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(projects); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProjectsExists(projects.projectId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(projects)); }
public async Task <IActionResult> PutVisits([FromRoute] int id, [FromBody] Visits visits) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } //if (id != visits.visitId) //{ // return BadRequest(); //} //_context.Entry(visits).State = EntityState.Modified; var list = await _context.Visits.AsNoTracking().ToListAsync(); //list.Where(s => s.visitId == id); foreach (Visits v in list) { if (v.visitId == id) { visits.dateCreated = v.dateCreated; visits.visitDate = v.visitDate; break; } } try { visits.visitId = id; //return Ok("开始更新" + visits.dateCreated + " " + visits.GetType()+" "+visits.visitId); _context.Update(visits); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException e) { if (!VisitsExists(id)) { return(NotFound()); } else { return(BadRequest(e.Message.ToString())); } } APIReturn re = new APIReturn(); re.Status = "success"; return(Ok(re)); }
public async Task <IActionResult> PutAwards([FromRoute] int id, [FromBody] Awards awards) { if (!ModelState.IsValid) { APIReturn re4 = new APIReturn(); re4.Status = "Failed"; return(BadRequest(re4)); } if (id != awards.awardId) { APIReturn re2 = new APIReturn(); re2.Status = "Failed"; return(BadRequest(re2)); } //_context.Entry(awards).State = EntityState.Modified; var list = await _context.Awards.AsNoTracking().SingleAsync(s => s.awardId == id); awards.dateCreated = list.dateCreated; awards.awardId = id; try { _context.Update(awards); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AwardsExists(id)) { APIReturn re1 = new APIReturn(); re1.Status = "Failed"; return(BadRequest(re1)); } else { throw; } } APIReturn re = new APIReturn(); re.Status = "success"; return(Ok(re)); }
public async Task <IActionResult> AddOrEdit([Bind("EmployeeId,FullName,EmpCode,Position,OfficeLocation")] Employee employee) { if (ModelState.IsValid) { if (employee.EmployeeId == 0) { _context.Add(employee); } else { _context.Update(employee); } await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(employee)); }
public async Task <IActionResult> PutShortCourses([FromRoute] int id, [FromBody] ShortCourses shortCourses) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != shortCourses.courseId) { return(BadRequest()); } // _context.Entry(shortCourses).State = EntityState.Modified; var list = await _context.ShortCourses.AsNoTracking().SingleAsync(s => s.courseId == id); shortCourses.dateCreated = list.dateCreated; shortCourses.courseId = id; try { _context.Update(shortCourses); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ShortCoursesExists(id)) { return(NotFound()); } else { throw; } } APIReturn re = new APIReturn(); re.Status = "success"; return(Ok(re)); }
public async Task <IActionResult> Edit(int id, [Bind("presetId,dateCreated,themeId,visitId")] Preset preset) { if (id != preset.presetId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(preset); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PresetExists(preset.presetId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } var list = _context.Visits.ToList(); var selectlist = new SelectList(list, "visitId", "companyName"); ViewBag.selectlist = selectlist; var themelist = _context.Theme.ToList(); var namelist = new SelectList(themelist, "themeId", "themeName"); ViewBag.namelist = namelist; return(View(preset)); }
#pragma warning disable 1998 public async override global::System.Threading.Tasks.Task ExecuteAsync() { BeginContext(52, 2, true); WriteLiteral("\r\n"); EndContext(); #line 3 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Projects\Index.cshtml" ViewData["Title"] = "All project"; #line default #line hidden BeginContext(101, 116, true); WriteLiteral("\r\n<p align=\"center\" style=\"font-size:50px;margin-top:50px;\" class=\"title\">All projects</p>\r\n<p align=\"center\">\r\n "); EndContext(); BeginContext(217, 58, false); __tagHelperExecutionContext = __tagHelperScopeManager.Begin("a", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "3daaad8a8dbb4c6f85492a30b031479b", async() => { BeginContext(261, 10, true); WriteLiteral("Create New"); EndContext(); } ); __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper>(); __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper); __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_0); __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.Action = (string)__tagHelperAttribute_1.Value; __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_1); await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); if (!__tagHelperExecutionContext.Output.IsContentModified) { await __tagHelperExecutionContext.SetOutputContentAsync(); } Write(__tagHelperExecutionContext.Output); __tagHelperExecutionContext = __tagHelperScopeManager.End(); EndContext(); BeginContext(275, 6, true); WriteLiteral("\r\n "); EndContext(); BeginContext(281, 64, false); __tagHelperExecutionContext = __tagHelperScopeManager.Begin("a", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "a62a2e6ec8ab4cf39be6b58c3328f4f7", async() => { BeginContext(328, 13, true); WriteLiteral("Query project"); EndContext(); } ); __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper>(); __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper); __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_0); __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.Action = (string)__tagHelperAttribute_2.Value; __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_2); await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); if (!__tagHelperExecutionContext.Output.IsContentModified) { await __tagHelperExecutionContext.SetOutputContentAsync(); } Write(__tagHelperExecutionContext.Output); __tagHelperExecutionContext = __tagHelperScopeManager.End(); EndContext(); BeginContext(345, 313, true); WriteLiteral(@" </p> <div class=""row""> <!-- column --> <div class=""col-sm-12""> <div class=""card""> <div class=""table-responsive""> <table class=""table""> <thead> <tr> <th> "); EndContext(); BeginContext(659, 47, false); #line 21 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Projects\Index.cshtml" Write(Html.DisplayNameFor(model => model.projectName)); #line default #line hidden EndContext(); BeginContext(706, 103, true); WriteLiteral("\r\n </th>\r\n <th>\r\n "); EndContext(); BeginContext(810, 48, false); #line 24 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Projects\Index.cshtml" Write(Html.DisplayNameFor(model => model.projectState)); #line default #line hidden EndContext(); BeginContext(858, 103, true); WriteLiteral("\r\n </th>\r\n <th>\r\n "); EndContext(); BeginContext(962, 48, false); #line 27 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Projects\Index.cshtml" Write(Html.DisplayNameFor(model => model.noOfStudents)); #line default #line hidden EndContext(); BeginContext(1010, 103, true); WriteLiteral("\r\n </th>\r\n <th>\r\n "); EndContext(); BeginContext(1114, 47, false); #line 30 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Projects\Index.cshtml" Write(Html.DisplayNameFor(model => model.dateCreated)); #line default #line hidden EndContext(); BeginContext(1161, 166, true); WriteLiteral("\r\n </th>\r\n <th></th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n"); EndContext(); #line 36 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Projects\Index.cshtml" CMSContext context = new CMSContext(); var list = context.Student.ToList(); #line default #line hidden BeginContext(1516, 24, true); WriteLiteral(" "); EndContext(); #line 40 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Projects\Index.cshtml" foreach (var item in Model) { #line default #line hidden BeginContext(1597, 134, true); WriteLiteral(" <tr>\r\n <td style=\"line-height:40px;\">\r\n "); EndContext(); BeginContext(1732, 46, false); #line 44 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Projects\Index.cshtml" Write(Html.DisplayFor(modelItem => item.projectName)); #line default #line hidden EndContext(); BeginContext(1778, 141, true); WriteLiteral("\r\n </td>\r\n <td style=\"line-height:40px;\">\r\n "); EndContext(); BeginContext(1920, 47, false); #line 47 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Projects\Index.cshtml" Write(Html.DisplayFor(modelItem => item.projectState)); #line default #line hidden EndContext(); BeginContext(1967, 105, true); WriteLiteral("\r\n </td>\r\n <td style=\"line-height:40px;\">\r\n"); EndContext(); #line 50 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Projects\Index.cshtml" int i = 0; foreach (Student student in list) { if (student.projectId == item.projectId) { i++; } } context.Update(item); await context.SaveChangesAsync(); #line default #line hidden BeginContext(2736, 36, true); WriteLiteral(" "); EndContext(); BeginContext(2773, 31, false); #line 62 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Projects\Index.cshtml" Write(Html.DisplayFor(modelItem => i)); #line default #line hidden EndContext(); BeginContext(2804, 105, true); WriteLiteral("\r\n </td>\r\n <td style=\"line-height:40px;\">\r\n"); EndContext(); BeginContext(2975, 36, true); WriteLiteral(" "); EndContext(); #line 66 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Projects\Index.cshtml" string datecreated = item.dateCreated.ToString("dd MMM yyyy,hh:mm", DateTimeFormatInfo.InvariantInfo); #line default #line hidden BeginContext(3198, 36, true); WriteLiteral(" "); EndContext(); BeginContext(3235, 41, false); #line 69 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Projects\Index.cshtml" Write(Html.DisplayFor(modelItem => datecreated)); #line default #line hidden EndContext(); BeginContext(3276, 141, true); WriteLiteral("\r\n </td>\r\n <td style=\"line-height:40px;\">\r\n "); EndContext(); BeginContext(3417, 84, false); __tagHelperExecutionContext = __tagHelperScopeManager.Begin("a", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "0d6c696c725847f894be4056d453b92b", async() => { BeginContext(3493, 4, true); WriteLiteral("Edit"); EndContext(); } ); __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper>(); __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper); __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.Action = (string)__tagHelperAttribute_3.Value; __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_3); if (__Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.RouteValues == null) { throw new InvalidOperationException(InvalidTagHelperIndexerAssignment("asp-route-id", "Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper", "RouteValues")); } BeginWriteTagHelperAttribute(); #line 72 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Projects\Index.cshtml" WriteLiteral(item.projectId); #line default #line hidden __tagHelperStringValueBuffer = EndWriteTagHelperAttribute(); __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.RouteValues["id"] = __tagHelperStringValueBuffer; __tagHelperExecutionContext.AddTagHelperAttribute("asp-route-id", __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.RouteValues["id"], global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_4); await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); if (!__tagHelperExecutionContext.Output.IsContentModified) { await __tagHelperExecutionContext.SetOutputContentAsync(); } Write(__tagHelperExecutionContext.Output); __tagHelperExecutionContext = __tagHelperScopeManager.End(); EndContext(); BeginContext(3501, 2, true); WriteLiteral("\r\n"); EndContext(); BeginContext(3632, 36, true); WriteLiteral(" "); EndContext(); BeginContext(3668, 87, false); __tagHelperExecutionContext = __tagHelperScopeManager.Begin("a", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "58e04654066541e4937db86bc175dbf5", async() => { BeginContext(3745, 6, true); WriteLiteral("Delete"); EndContext(); } ); __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper>(); __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper); __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.Action = (string)__tagHelperAttribute_5.Value; __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_5); if (__Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.RouteValues == null) { throw new InvalidOperationException(InvalidTagHelperIndexerAssignment("asp-route-id", "Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper", "RouteValues")); } BeginWriteTagHelperAttribute(); #line 74 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Projects\Index.cshtml" WriteLiteral(item.projectId); #line default #line hidden __tagHelperStringValueBuffer = EndWriteTagHelperAttribute(); __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.RouteValues["id"] = __tagHelperStringValueBuffer; __tagHelperExecutionContext.AddTagHelperAttribute("asp-route-id", __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.RouteValues["id"], global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_6); await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); if (!__tagHelperExecutionContext.Output.IsContentModified) { await __tagHelperExecutionContext.SetOutputContentAsync(); } Write(__tagHelperExecutionContext.Output); __tagHelperExecutionContext = __tagHelperScopeManager.End(); EndContext(); BeginContext(3755, 76, true); WriteLiteral("\r\n </td>\r\n </tr>\r\n"); EndContext(); #line 77 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Projects\Index.cshtml" } #line default #line hidden BeginContext(3858, 128, true); WriteLiteral(" </tbody>\r\n </table>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n"); EndContext(); }