public async Task <IActionResult> Edit(Guid id, [Bind("WebCheckID,Name,Domain,Delay,CreateDate,AccountID")] WebCheck webCheck) { if (id != webCheck.WebCheckID) { return(NotFound()); } if (ModelState.IsValid) { try { // Set DateTime new webCheck.CreateDate = DateTime.Now; _context.Update(webCheck); await _context.SaveChangesAsync(); WebCheckHelper.UpdateRecurringEvent(webCheck); } catch (DbUpdateConcurrencyException) { if (!WebCheckExists(webCheck.WebCheckID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["AccountID"] = new SelectList(_context.Accounts, "AccountID", "Password", webCheck.AccountID); return(View(webCheck)); }
public async Task <IActionResult> DeleteConfirmed(Guid id) { var webCheck = await _context.WebChecks.FindAsync(id); _context.WebChecks.Remove(webCheck); await _context.SaveChangesAsync(); WebCheckHelper.DeleteRecurringEvent(webCheck); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Create([Bind("WebCheckID,Name,Domain,Delay,CreateDate,AccountID")] WebCheck webCheck) { if (ModelState.IsValid) { var userAccount = GetUserAccountAsync().Result; webCheck.WebCheckID = Guid.NewGuid(); webCheck.CreateDate = DateTime.Now; webCheck.AccountID = userAccount.AccountID; _context.Add(webCheck); await _context.SaveChangesAsync(); WebCheckHelper.CreateRecurringEvent(webCheck); return(RedirectToAction(nameof(Index))); } ViewData["AccountID"] = new SelectList(_context.Accounts, "AccountID", "Password", webCheck.AccountID); return(View(webCheck)); }