public void The_Controller_Should_Be_Able_To_Save_The_Runtime_To_Db()
        {
            RuntimeController runtimeCtrl = null;
            CheckpointModel checkpoint = null;

            int runtime = 360000000; // Runtime, in milliseconds. Equals 100 hours.
            ContentResult webResponse = null;

            Given("we have a timer and the time keeper wants to save a runtime", () =>
            {
                checkpoint = new CheckpointModel("TheRuntimeCheckpoint", timer, race);
                checkpoint = new CheckpointModel("TheRuntimeCheckpoint", timer, race);
                checkpoint.Sortorder = 1;
            });

            When("the time keeper saves the runtime", () =>
            {
                runtimeCtrl = new RuntimeController();
                webResponse = (ContentResult)runtimeCtrl.Save(runtime.ToString(), checkpoint.Id.ToString());
            });

            Then("the runtime should be saved in the database", () =>
            {
                int runtimeId = Int32.Parse(webResponse.Content);
                RuntimeModel runtimeStoredInDb = RuntimeModel.getById(runtimeId);
                runtimeStoredInDb.Runtime.ShouldBe(runtime);
            });
        }
Exemple #2
0
        public ActionResult SelfStudy()
        {
            CheckpointBL    _chkBL   = new CheckpointBL();
            CheckpointModel chkModel = new CheckpointModel();

            chkModel = _chkBL.GetActiveCheckpoint();

            if (Session["StarsIdProfile"] != null)
            {
                string  pacode       = Session["w_pacode"].ToString();
                decimal checkpointId = chkModel.CHECKPOINT_ID;

                if (_chkBL.CheckCheckpointCompleted(pacode, checkpointId))
                {
                    return(PartialView("_Completed", chkModel));
                }
                if (chkModel.CHECKPOINT_ID == 1)
                {
                    return(PartialView("_SelfStudy"));
                }
                if (chkModel.CHECKPOINT_ID == 2)
                {
                    return(PartialView("_SelfStudy2"));
                }
            }
            return(RedirectToAction("Welcome", "LBC"));
        }
Exemple #3
0
        public ActionResult Clicks(string file)
        {
            string filename = "";
            int    Position = file.LastIndexOf("/");

            filename = file.Substring(Position + 1);
            CheckpointBL       _chkBL     = new CheckpointBL();
            CheckpointTracking chkModel   = new CheckpointTracking();
            CheckpointModel    chkpPModel = new CheckpointModel();

            chkpPModel             = _chkBL.GetActiveCheckpoint();
            chkModel.CHECKPOINT_ID = chkpPModel.CHECKPOINT_ID;// Convert.ToDecimal(Session["CheckId"].ToString());
            chkModel.CREATED_DATE  = DateTime.Now;
            chkModel.DOWNLOAD_TIME = DateTime.Now;
            chkModel.CREATED_BY    = Session["w_user"].ToString().ToUpper();
            chkModel.DOC_URL       = file;
            chkModel.FILE_NAME     = filename;
            chkModel.PA_CODE       = Session["w_pacode"].ToString();
            chkModel.STARS_ID      = Session["StarsIdProfile"].ToString();

            _chkBL.SaveCheckpointTracking(chkModel);
            //saveClick();
            return(Json(new
            {
                //redirectUrl = Url.Action("Presentation", "Toolkit"),
                isRedirect = true,
                JsonRequestBehavior.AllowGet
            }));
        }
Exemple #4
0
        public ActionResult Completed()
        {
            CheckpointBL    _chkBL   = new CheckpointBL();
            CheckpointModel chkModel = new CheckpointModel();

            chkModel = _chkBL.GetActiveCheckpoint();
            return(PartialView("_Completed", chkModel));
        }
 public CheckpointPropertiesWindow(Checkpoint checkpoint, Canvas canvas, DesignerItem item, Level level)
     : base()
 {
     InitializeComponent();
     item.PropertyWindow = this;
     DataContext = new CheckpointModel(checkpoint, item, level, canvas);
     (DataContext as CheckpointModel).RespawnIndicator.OnSelected += HandleSelection;
 }
 public void TestSetup()
 {
     timeMerger = new TimeMergerModel();
     timer = new TimerModel();
     checkpoint1 = new CheckpointModel("Checkpoint1", timer, 1);
     checkpoint2 = new CheckpointModel("Checkpoint2", timer, 2);
     timer.CurrentCheckpointId = timer.GetFirstCheckpointId();
     timer.CheckpointRuntimes.Add(timer.CurrentCheckpointId, new Dictionary<int, int>());
     checkpointOrderModel = new CheckpointOrderModel();
 }
 public ActionResult Create(int raceId, string txtCheckpointName)
 {
     if (String.IsNullOrEmpty(txtCheckpointName))
     {
         SetTempData(KEY_NAME_EMPTY, true);
     }
     else
     {
         CheckpointModel model = new CheckpointModel(txtCheckpointName, raceId); // race with raceId exists in the database already.
         model.SaveToDb();
         SetTempData(KEY_A_CHECKPOINT_WAS_CREATED_SUCCESSFULLY, true);
     }
     return RedirectToAction("Create"); // Redirect in order to reset form values.
 }
Exemple #8
0
        public ActionResult PhysicalTool(FormCollection frm)
        {
            Session["tool"] = frm["radio"];

            if (Session["CheckId"].ToString() == "1")
            {
                return(Json(new
                {
                    redirectUrl = Url.Action("Presentation", "Toolkit"),
                    isRedirect = true
                }));
            }
            if (Session["CheckId"].ToString() == "2")
            {
                if (Session["StarsIdProfile"] != null)
                {
                    CheckpointBL             _chkBL   = new CheckpointBL();
                    CheckpointCompletedModel chkModel = new CheckpointCompletedModel();
                    chkModel = _chkBL.GetUserEmail(Session["StarsIdProfile"].ToString());
                    //
                    CheckpointModel chkpModel = new CheckpointModel();
                    chkpModel = _chkBL.GetActiveCheckpoint();

                    chkModel.STARS_ID      = Session["StarsIdProfile"].ToString();
                    chkModel.PA_CODE       = Session["w_pacode"].ToString();
                    chkModel.CHECKPOINT_ID = chkpModel.CHECKPOINT_ID;//Convert.ToDecimal(Session["CheckId"].ToString());
                    //chkModel.EMAIL_ID = Session["email"].ToString();
                    chkModel.TOOL_ORDERED = Session["tool"].ToString();
                    //

                    //

                    chkModel.CREATED_BY   = Session["w_user"].ToString().ToUpper();
                    chkModel.CREATED_DATE = DateTime.Now;

                    if (!(_chkBL.CheckCheckpointCompleted(chkModel.PA_CODE, chkModel.CHECKPOINT_ID)))
                    {
                        _chkBL.SaveCheckpointOrder(chkModel);
                        EmailHelper.SendCheckpointEmail(chkModel.EMAIL_ID, chkModel.TOOL_ORDERED);
                    }
                }
                return(Json(new
                {
                    redirectUrl = Url.Action("Completed", "Toolkit"),
                    isRedirect = true
                }));
            }
            return(RedirectToAction("Welcome", "LBC"));
        }
Exemple #9
0
        public ActionResult Index()
        {
            CheckpointBL    _chkBL   = new CheckpointBL();
            CheckpointModel chkModel = new CheckpointModel();

            chkModel             = _chkBL.GetActiveCheckpoint();
            chkModel.CHECKPOINTS = _chkBL.GetInactiveCheckpoints();

            if (Session["StarsIdProfile"] != null)
            {
                Session["CheckId"] = chkModel.CHECKPOINT_ID;
                return(View(chkModel));
            }
            return(RedirectToAction("Welcome", "LBC"));
        }
Exemple #10
0
        public void It_Should_Be_Possible_To_Insert_A_New_Checkpoint_To_The_Database()
        {
            CheckpointModel newCheckpoint = null;
            Given("we want to insert a new checkpoint to the database");

            When("we create the checkpoint", () =>
            {
                newCheckpoint = new CheckpointModel("MyCheckpoint", timer, race, 1);
                newCheckpoint = new CheckpointModel("MyCheckpoint", new TimerModel(), race, 1);
            });

            Then("it should exist in the database", () =>
            {
                CheckpointModel checkpointDb = CheckpointModel.getById(newCheckpoint.Id);
                checkpointDb.ShouldBe(newCheckpoint);
            });
        }
Exemple #11
0
        public void A_Checkpoint_Should_Be_Able_To_Have_A_Timer()
        {
            Given("we have a timer", () =>
            {
            });

            When("when we create a checkpoint and associate it with a timer", () =>
            {
                checkpoint = new CheckpointModel("Supercheckpoint", timer, race);
            });

            Then("the checkpoint should have the correct timer associated with it", () =>
            {
                CheckpointModel checkpointDb = CheckpointModel.getById(checkpoint.Id);
                checkpointDb.Timer.ShouldBe(timer);
            });
        }
Exemple #12
0
 public ActionResult Presentation()
 {
     if (Session["StarsIdProfile"] != null)
     {
         CheckpointBL    _chkBL    = new CheckpointBL();
         CheckpointModel chkpModel = new CheckpointModel();
         chkpModel = _chkBL.GetActiveCheckpoint();
         CheckpointCompletedModel chkModel = new CheckpointCompletedModel();
         chkModel.STARS_ID      = Session["StarsIdProfile"].ToString();
         chkModel.PA_CODE       = Session["w_pacode"].ToString();
         chkModel.CHECKPOINT_ID = chkpModel.CHECKPOINT_ID;//Convert.ToDecimal(Session["CheckId"].ToString());
         chkModel.EMAIL_ID      = Session["email"].ToString();
         chkModel.TOOL_ORDERED  = Session["tool"].ToString();
         return(PartialView("_Presentation", chkModel));
     }
     return(RedirectToAction("Welcome", "LBC"));
 }
Exemple #13
0
        public IActionResult Post(int competitionID, [FromBody] CheckpointModel input)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var newCheckpoint = new Checkpoint
            {
                Code    = input.Code,
                StageID = input.StageId
            };

            _context.Checkpoints.Add(newCheckpoint);
            _context.SaveChanges();

            input.Id = newCheckpoint.ID;

            return(Ok(input));
        }
Exemple #14
0
        public ActionResult Presentation(FormCollection frm)
        {
            if (Session["StarsIdProfile"] != null)
            {
                CheckpointBL    _chkBL     = new CheckpointBL();
                CheckpointModel chkpPModel = new CheckpointModel();
                chkpPModel = _chkBL.GetActiveCheckpoint();

                CheckpointCompletedModel chkModel = new CheckpointCompletedModel();
                chkModel.STARS_ID      = frm["STARS_ID"];
                chkModel.PA_CODE       = frm["PA_CODE"];
                chkModel.CHECKPOINT_ID = chkpPModel.CHECKPOINT_ID;//Convert.ToDecimal(frm["CHECKPOINT_ID"]);
                chkModel.TOOL_ORDERED  = frm["TOOL_ORDERED"];
                chkModel.EMAIL_ID      = frm["EMAIL_ID"];
                chkModel.CREATED_BY    = Session["w_user"].ToString().ToUpper();
                chkModel.CREATED_DATE  = DateTime.Now;

                if (!(_chkBL.CheckCheckpointCompleted(chkModel.PA_CODE, chkModel.CHECKPOINT_ID)))
                {
                    _chkBL.SaveCheckpointOrder(chkModel);
                    EmailHelper.SendCheckpointEmail(chkModel.EMAIL_ID, chkModel.TOOL_ORDERED);
                    CheckpointReportBL    _chkrBL   = new CheckpointReportBL();
                    CheckpointReportModel chkrmodel = new CheckpointReportModel();
                    chkrmodel = _chkrBL.GetCheckpointInfoByStarsId(chkModel.STARS_ID);
                    //removed this as part of request: 20262 - 0024482 Dashboard Updates - 4.7.15
                    //EmailHelper.SendCheckpointEmailAdmin(chkrmodel);

                    return(Json(new
                    {
                        redirectUrl = Url.Action("Completed", "Toolkit"),
                        isRedirect = true
                    }));
                }
                return(Json(new
                {
                    redirectUrl = Url.Action("Completed", "Toolkit"),
                    isRedirect = true
                }));
            }
            return(RedirectToAction("Welcome", "LBC"));
        }
        /// <summary>
        /// Get active checkpoint
        /// </summary>
        /// <returns></returns>
        public CheckpointModel GetActiveCheckpoint()
        {
            CheckpointModel model = new CheckpointModel();

            using (LBCData context = new LBCData(ConnectionHelper.getConnectionString()))
            {
                var chk = from entity in context.LBC_CHECKPOINT
                          where (entity.CHK_START_DATE <DateTime.Now && entity.CHK_END_DATE> DateTime.Now)
                          select new CheckpointModel
                {
                    CHECKPOINT_ID  = entity.CHECKPOINT_ID,
                    CHK_DESC       = entity.CHK_DESC,
                    CHK_START_DATE = entity.CHK_START_DATE,
                    CHK_END_DATE   = entity.CHK_END_DATE,
                    CHK_TITLE      = entity.CHK_TITLE,
                    IMAGE_NAME     = entity.IMAGE_NAME
                };
                model = chk.SingleOrDefault();
            }
            return(model);
        }
 /// <summary>
 /// Creates the new timer model with checkpoints.
 /// </summary>
 /// <returns></returns>
 private void Setup()
 {
     eventModel = new EventModel("Testevent", DateTime.Today);
     eventModel.Save();
     race = new RaceModel("Testrace", DateTime.Today);
     race.EventId = eventModel.EventId;
     race.Save();
     timer = new TimerModel();
     timer.RaceID = race.RaceId;
     checkpoint = new CheckpointModel("Checkpoint1", timer, race, 1);
     checkpoint.SaveToDb();
     checkpointorder = new CheckpointOrderModel();
     checkpointorder.AddCheckpointOrderDB(checkpoint.Id, 12);
     checkpointorder.StartingNumber = 12;
     timer.CurrentCheckpointId = timer.GetFirstCheckpointId();
     timer.CheckpointRuntimes.Add(timer.CurrentCheckpointId, new Dictionary<int, int>());
     timer.SaveToDb();
     timestart = new TimeStartnumberModel(timer);
     timestart.CheckpointOrder = checkpointorder;
     //timestart.AddStartnumber(checkpoint.Id, checkpointorder.StartingNumber, 500);
 }
        public async Task <ICheckpoint> GetCheckpointAsync(IndexType indexType)
        {
            if (_saveProgress)
            {
                var paritionKey = indexType.ToString().ToLowerInvariant();
                var operation   = TableOperation.Retrieve <CheckpointAdapter>(paritionKey, string.Empty);
                var response    = await _storageClient.GetCheckpointTable().ExecuteAsync(
                    operation, new TableRequestOptions(), new OperationContext(), _cancellationToken);

                if (response.Result != null)
                {
                    return((CheckpointAdapter)response.Result);
                }
            }

            var checkpoint = new CheckpointModel
            {
                IndexType = indexType
            };
            var genesisHash = _network.GetGenesis().Header.GetHash();

            checkpoint.BlockLocator.Blocks.Add(genesisHash);
            return(new CheckpointAdapter(checkpoint));
        }
Exemple #18
0
        public void We_Should_Be_Able_To_Insert_And_Fetch_A_Checkpoint_To_Database()
        {
            CheckpointModel checkpointDb = null;

            Given("we have a checkpoint", () =>
            {
                checkpoint = new CheckpointModel("MyCheckpoint", timer, race, 1);
            });

            When("we fetch the same checkpoint from database", () =>
            {
                checkpointDb = CheckpointModel.getById(checkpoint.Id);
            });

            Then("the checkpoints should be the same", () =>
            {
                checkpointDb.ShouldBe(checkpoint);
            });
        }
Exemple #19
0
        public void The_Checkpoint_Should_Have_A_Timer_With_Correct_Start_Time_When_Starting_The_Timer()
        {
            Given("we have a timer which is associated with a checkpoint", () =>
            {
                checkpoint = new CheckpointModel("RelationToTimerCheckpoint", timer, race);
            });

            When("we start the timer", () => timer.Start());

            Then("the checkpoint should have a timer with the correct start time", () =>
            {
                CheckpointModel checkpointDb = CheckpointModel.getById(checkpoint.Id);
                checkpointDb.Timer.StartTime.ShouldBe(timer.StartTime);
            });
        }
Exemple #20
0
 public void TestSetup()
 {
     club = new ClubModel("Test IK");
     eventModel = new EventModel("TestEvent", DateTime.Today);
     eventModel.Save();
     athlete = new AthleteModel("Tester", "Test");
     athlete.StartNumber = 1;
     athlete.Club = club;
     athlete.SaveToDb();
     race = new RaceModel("TestRace", DateTime.Today);
     race.EventId = eventModel.EventId;
     race.Save();
     checkpointOrder = null;
     intermediate = null;
     checkpoint = null;
 }
Exemple #21
0
 public IActionResult Update(int competitionID, int checkpointID, [FromBody] CheckpointModel input)
 {
     return(Ok());
 }
 public void TestSetup()
 {
     timeMerger = new TimeMergerModel();
     timer = new TimerModel();
     eventModel = new EventModel("Testevent", DateTime.Today);
     eventModel.Save();
     race = new RaceModel("SomeRace", new DateTime(2007, 10, 3));
     race.EventId = eventModel.EventId;
     race.Save();
     checkpoint1 = new CheckpointModel("Checkpoint1", timer, race, 1);
     checkpoint2 = new CheckpointModel("Checkpoint2", timer, race, 2);
     timer.RaceID = race.RaceId;
     timer.CurrentCheckpointId = timer.GetFirstCheckpointId();
     timer.CheckpointRuntimes.Add(timer.CurrentCheckpointId, new Dictionary<int, int>());
     checkpointOrderModel = new CheckpointOrderModel();
     timestartnumberModel = new TimeStartnumberModel(timer);
     timestartnumberModel.ChangeCheckpoint(timer.GetFirstCheckpointId());
     timestartnumberModel.CheckpointOrder = checkpointOrderModel;
 }
Exemple #23
0
 public void TestSetup()
 {
     timer = new TimerModel();
     eventModel = new EventModel("TestEvent", DateTime.Today);
     eventModel.Save();
     race = new RaceModel("SomeRace", new DateTime(2007, 10, 3));
     race.EventId = eventModel.EventId;
     race.Save();
     checkpoint = new CheckpointModel("Checkpoint1", timer, race, 1);
     checkpoint2 = new CheckpointModel("Checkpoint2", timer, race, 2);
     timer.CurrentCheckpointId = timer.GetFirstCheckpointId();
     timer.CheckpointRuntimes.Add(timer.CurrentCheckpointId, new Dictionary<int, int>());
 }
Exemple #24
0
 /// <summary>
 /// Creates the new timer model with checkpoints.
 /// </summary>
 /// <returns></returns>
 private TimerModel CreateNewTimerModelWithCheckpoints(RaceModel race)
 {
     timer = new TimerModel();
     timer.RaceID = race.RaceId;
     checkpoint = new CheckpointModel("Checkpoint1", timer, race, 1);
     timer.CurrentCheckpointId = timer.GetFirstCheckpointId();
     timer.CheckpointRuntimes.Add(timer.CurrentCheckpointId, new Dictionary<int, int>());
     return timer;
 }