コード例 #1
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            Info.TestDate = DateTime.ParseExact(DateEdit, "MM/dd/yyyy", null);

            _context.Attach(Info).State = EntityState.Modified;
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!InfoExists(Info.ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            string sessionv = HttpContext.Session.GetString("InfosPage");

            return(Redirect(sessionv));
        }
コード例 #2
0
ファイル: Edit.cshtml.cs プロジェクト: Rohan12UC21/WU-APP
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Attach(Server).State = EntityState.Modified;
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ServerExists(Server.ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
コード例 #3
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Info.Add(Info);
            await _context.SaveChangesAsync();

            string sessionv = HttpContext.Session.GetString("InfosPage");

            return(Redirect(sessionv));
        }
コード例 #4
0
        public async Task<IActionResult> OnPostAsync(int? id)
        {
            if (id == null)
            {
                return NotFound();
            }

            Server = await _context.Server.FindAsync(id);

            if (Server != null)
            {
                _context.Server.Remove(Server);
                await _context.SaveChangesAsync();
            }

            return RedirectToPage("./Index");
        }
コード例 #5
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Info = await _context.Info.FindAsync(id);

            if (Info != null)
            {
                _context.Info.Remove(Info);
                await _context.SaveChangesAsync();
            }

            string sessionv = HttpContext.Session.GetString("InfosPage");

            return(Redirect(sessionv));
        }
コード例 #6
0
        public async Task <IActionResult> OnPostAsync()
        {
            HttpContext.Session.SetString("NoAccess", "");
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            if (CheckServer.Check(Server))
            {
                HttpContext.Session.SetString("NoAccess", "You do not have access to this server");
                NoAccessMsg = HttpContext.Session.GetString("NoAccess");
                return(null);
            }

            _context.Server.Add(Server);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
コード例 #7
0
ファイル: Index.cshtml.cs プロジェクト: Rohan12UC21/WU-APP
        public async Task OnGetAsync()
        {
            IUrlHelper MyUrl = Url;
            string     My    = HttpContext.Request.Scheme + "://" + HttpContext.Request.Host.ToString() + HttpContext.Request.Path + HttpContext.Request.QueryString;

            HttpContext.Session.SetString("InfosPage", My);
            SelectLists();
            Check();
            FilteredPage = HttpContext.Session.GetString("InfosPage");

            var infos = from m in _context.Info
                        select m;


            if (!string.IsNullOrEmpty(SearchKBID))
            {
                infos = infos.Where(s => s.KBID.Contains(SearchKBID));
            }

            if (!string.IsNullOrEmpty(SearchICW))
            {
                infos = infos.Where(s => s.ICW.Contains(SearchICW));
            }

            if (!string.IsNullOrEmpty(SelectedResult))
            {
                infos = infos.Where(x => x.TestResults == SelectedResult);
            }

            if (!string.IsNullOrEmpty(SelectedServer))
            {
                infos = infos.Where(x => x.Server == SelectedServer);
            }


            if (!string.IsNullOrEmpty(datefilter))
            {
                string start = datefilter.Split(" - ")[0];
                string end   = datefilter.Split(" - ")[1];

                DateTime startDate = DateTime.ParseExact(start, "MM/dd/yyyy", null);
                DateTime endDate   = DateTime.ParseExact(end, "MM/dd/yyyy", null);

                infos = infos.Where(d => d.TestDate >= startDate && d.TestDate <= endDate);
            }


            foreach (Info temp in _context.Info)
            {
                DateTime current = DateTime.Now;
                if (temp.TestDate <= current.AddMonths(-2))
                {
                    temp.Active = "No";
                    _context.Info.Update(temp);
                }
            }


            Info = await infos.ToListAsync();

            await _context.SaveChangesAsync();
        }