public HomeController(Model.ModelDataContext modelDB, UserManager <Identity.IdentityUser> userManager, SignInManager <Identity.IdentityUser> signInManager, IConfiguration config)
 {
     this._userManager   = userManager;
     this._signInManager = signInManager;
     this._config        = config;
     this._modelDB       = modelDB;
 }
        public SyncController(Sync.SyncDataContext db, Model.ModelDataContext modelDataContext, IUserStore <Identity.IdentityUser> userStore, UserManager <Identity.IdentityUser> userManager, ILogger <SyncController> logger, IConfiguration config)
        {
            _db          = db;
            _modelDb     = modelDataContext;
            _userStore   = userStore;
            _userManager = userManager;
            _logger      = logger;
            _config      = config;

            _syncKey = config.GetSection("Sync").GetValue <string>("ServiceKey");
        }
Example #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // define the user id
            var userId = Convert.ToString(Membership.GetUser().ProviderUserKey);

            // define the model
            using (var model = new Model.ModelDataContext())
            {
                var currentAchievement = model.Achievements.FirstOrDefault(x => x.UserId.ToString() == userId);

                if (currentAchievement != null)
                {
                    switch (currentAchievement.AchievementLevel)
                    {
                    case 1:
                    {
                        Image1.ImageUrl = "~/img/Trophy3.png";
                        break;
                    }

                    case 2:
                    {
                        Image1.ImageUrl = "~/img/Trophy3.png";
                        Image2.ImageUrl = "~/img/Trophy4.png";
                        break;
                    }

                    case 3:
                    {
                        Image1.ImageUrl = "~/img/Trophy3.png";
                        Image2.ImageUrl = "~/img/Trophy4.png";
                        Image3.ImageUrl = "~/img/Trophy5.png";
                        break;
                    }
                    }
                }
            }
        }
 public MetricsController(Model.ModelDataContext modelDB, IAuthorizationService authorizationService, IServiceProvider serviceProvider)
 {
     _db = modelDB;
     _authorizationService = authorizationService;
     _serviceProvider      = serviceProvider;
 }
Example #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // define the level
            var level = Convert.ToInt32(Request.QueryString["level"]);

            var userId = Convert.ToString(Membership.GetUser().ProviderUserKey);

            // define the user id

            // define the model
            using (var model = new Model.ModelDataContext())
            {
                var readOnly = Request.QueryString["readonly"];

                if (readOnly != null && Convert.ToInt32(readOnly) == 1)
                {
                }
                else
                {
                    // define the result
                    var result = new Model.Result();

                    // assign the values
                    result.LevelScore = Convert.ToInt32(Request.QueryString["level"]);
                    result.UserId     = new Guid(userId);

                    // add the result
                    model.Results.InsertOnSubmit(result);

                    // commit
                    model.SubmitChanges();

                    // define the query
                    var query = model.Achievements.FirstOrDefault(x => x.UserId.ToString() == userId.ToString());

                    // determine if there is a match
                    if (query != null)
                    {
                        // there is a match

                        // define the current achievement level
                        var currentAchievementLevel = query.AchievementLevel;

                        // define the new achievement level
                        var newAchievementLevel = GetAchievementLevel(level);

                        // determine if there is an upgrade
                        if (newAchievementLevel > currentAchievementLevel)
                        {
                            // there is an upgrade

                            // assign the new achievement level
                            query.AchievementLevel = newAchievementLevel.Value;

                            // commit
                            model.SubmitChanges();
                        }
                    }
                    else
                    {
                        // there is no match

                        // define the achievement
                        var achievement = new Model.Achievement();

                        // assign the values
                        achievement.UserId           = new Guid(userId);
                        achievement.AchievementLevel = GetAchievementLevel(level).Value;

                        // add the achievement
                        model.Achievements.InsertOnSubmit(achievement);

                        // commit
                        model.SubmitChanges();
                    }
                }

                // define the list
                var list = model.UserResultsViews.OrderByDescending(x => x.LevelScore).Take(10);

                // define the list of custom results
                var customResults = new List <CustomResult>();

                // define the index
                var index = 1;

                // loop through the list
                foreach (var current in list)
                {
                    // define the custom result
                    var customResult = new CustomResult();

                    // assign the values
                    customResult.Rank       = index;
                    customResult.Username   = current.UserName;
                    customResult.LevelScore = current.LevelScore;

                    // add the custom result
                    customResults.Add(customResult);

                    // increment the index
                    index++;
                }



                // assign the data source
                GridView1.DataSource = customResults;

                // bind the data
                GridView1.DataBind();
            }
        }