Beispiel #1
0
    public PartialViewResult ErrorView(string ddl)
    {
        var dbContext = new SemplestModel.Semplest();
        List<ErrorModel> list = new List<ErrorModel>();
        DateTime reqDate = DateTime.Parse(ddl);
        foreach (Error er in dbContext.Errors.Where(x => x.CreatedDate.Month == reqDate.Month && x.CreatedDate.Day == reqDate.Day && x.CreatedDate.Year == reqDate.Year).OrderByDescending(x => x.CreatedDate))
        {
            var em = new ErrorModel();
            em.ErrorMessage = er.ErrorMessage;
            em.User = er.User != null ? er.User.Credentials.First().Username : "******";
            em.TimeStamp = er.CreatedDate;

            list.Add(em);
        }
        return PartialView("_ErrorView", list);
    }
Beispiel #2
0
        //
        // GET: /Error/

        public ActionResult Index()
        {
            var dbContext = new SemplestModel.Semplest();
//            SortedList<DateTime, ErrorModel> list = new SortedList<DateTime, ErrorModel>();
            List<ErrorModel> list = new List<ErrorModel>();
            List<DateTime> dt = new List<DateTime>();
            ErrorModel em = null;
            DateTime t = DateTime.Now.Date;
            //foreach (Error er in dbContext.Errors.Where(x=>x.CreatedDate>t).OrderByDescending(x => x.CreatedDate))
            foreach (Error er in dbContext.Errors.OrderByDescending(x => x.CreatedDate))
            {
                em = new ErrorModel();
                em.ErrorMessage = er.ErrorMessage;
                em.User = er.User != null ? er.User.Credentials.First().Username : "******";
                em.TimeStamp = er.CreatedDate;
                if (!dt.Contains(er.CreatedDate.Date))
                    dt.Add(er.CreatedDate.Date);
                ViewData["CreateDate"] = new SelectList(dt, "Date", "Date");
                list.Add(em);
            }
            return View(list);
        }