Exemple #1
0
        public async Task <IActionResult> Edit(Guid id, [Bind("AccountID,Username,Password,Role")] Account account)
        {
            if (id != account.AccountID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(account);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AccountExists(account.AccountID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(account));
        }
Exemple #2
0
        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));
        }