public ActionResult Create(FormCollection collection)
        {
            try
            {
                var model = new AdHocPageModel();
                UpdateModel(model);

                var entity = new AdHocPage
                {
                    Url  = model.Url,
                    User = UserIdentity.GetShortName(User),
                    Test = true
                };

                using (var repo = new AdHocPageRepository())
                {
                    repo.Add(entity);
                    repo.SaveChanges();
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                var model = new AdHocPageModel();

                UpdateModel(model);

                using (var repo = new AdHocPageRepository())
                {
                    var entity = repo.GetById(model.Id);

                    entity.Url  = model.Url;
                    entity.User = UserIdentity.GetShortName(User);
                    entity.Test = model.Test;

                    repo.SaveChanges();
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
示例#3
0
        public ActionResult Delete()
        {
            var user = UserIdentity.GetShortName(User);

            using (var adHocPageStatusRepository = new AdHocPageStatusRepository())
            {
                adHocPageStatusRepository.DeleteAll(user);
            }

            return(RedirectToAction("Index"));
        }
示例#4
0
        // GET: AdHocTest
        public async Task <ActionResult> Index()
        {
            var listPageResponseModels = new List <PageResponseModel>();

            var timeZoneId  = "Eastern Standard Time";
            var easternZone = TimeZoneInfo.FindSystemTimeZoneById(timeZoneId);

            List <AdHocPage>      pages;
            List <AdHocPageStatu> listPageStatus;

            var user = UserIdentity.GetShortName(User);

            using (var adHocPageRepository = new AdHocPageRepository())
            {
                pages = adHocPageRepository.GetAllPagesToTestByUser(user);
            }

            //Hit each page from web job.
            foreach (var page in pages)
            {
                var aPageStatus = await HitPage(page.Url, user);
            }

            using (var adHocPageStatusRepository = new AdHocPageStatusRepository())
            {
                listPageStatus = adHocPageStatusRepository.GetPageStatuses();
            }

            foreach (var pageStatus in listPageStatus)
            {
                var utcTime = new DateTime(
                    pageStatus.Created.Year,
                    pageStatus.Created.Month,
                    pageStatus.Created.Day,
                    pageStatus.Created.Hour,
                    pageStatus.Created.Minute,
                    pageStatus.Created.Second);

                var easternTime = TimeZoneInfo.ConvertTimeFromUtc(utcTime, easternZone);

                listPageResponseModels.Add(
                    new PageResponseModel
                {
                    Created      = easternTime,
                    Url          = pageStatus.Url,
                    ResponseTime = pageStatus.ResponseTime,
                    Status       = pageStatus.Status
                });
            }

            return(View(listPageResponseModels));
        }
        // GET: PageAdmin
        public ActionResult Index()
        {
            var models = new List <AdHocPageModel>();

            var user     = User;
            var userName = user.Identity.GetUserName();

            using (var repo = new AdHocPageRepository())
            {
                var shortName = UserIdentity.GetShortName(User);
                var entities  = repo.GetAllByUser(shortName);

                models.AddRange(entities.Select(page => new AdHocPageModel
                {
                    Id   = page.Id,
                    Url  = page.Url,
                    Test = page.Test
                }));
            }

            return(View(models));
        }