コード例 #1
0
    public bool createNewStats(Double weight, Double height, LimitBreaker user)
    {
        bool rc = false;
        using (var context = new Layer2Container())
        {
            Statistics stats = new Statistics();

            stats.level = 1;
            stats.experience = 0;
            stats.weight = weight;
            stats.height = height;
            stats.rmr = 0;
            stats.bmi = 0;
            stats.vo2MAX = 0;

            stats.LimitBreaker = user;

            context.Statistics.AddObject(stats);
            context.SaveChanges();
            rc = true;
        }
        return rc;
    }
コード例 #2
0
    //rc status: 1 failure due to servers, 2 name already taken, 0 success
    public int createNewLimitBreaker(String username, String email, String gender, DateTime birthday, Double weight, Double height)
    {
        int rc = 1;

        using (var context = new Layer2Container())
        {
            LimitBreaker newLimitBreaker = new LimitBreaker();
            try
            {
                if ((context.LimitBreakers.FirstOrDefault(limitbreaker => limitbreaker.username == username).username == username) ||
                    (context.LimitBreakers.FirstOrDefault(limitbreaker => limitbreaker.email == email).email == email))
                {
                    rc = 2;
                    return rc;
                }
            }
            catch (NullReferenceException e)
            {
                newLimitBreaker.username = username;
                newLimitBreaker.gender = gender;
                newLimitBreaker.dateOfBirth = birthday;
                newLimitBreaker.email = email;
                newLimitBreaker.verified = false;
                newLimitBreaker.deactivated = false;

                context.LimitBreakers.AddObject(newLimitBreaker);

                if (createNewStats(weight, height, newLimitBreaker))
                {
                    rc = 0;
                }

            }
            return rc;
        }
    }
コード例 #3
0
    public void recordOldWeight(LimitBreaker user, Double weight, Layer2Container context)
    {
        OldWeight oldWeight = new OldWeight();
        oldWeight.LimitBreaker = user;
        oldWeight.date = DateTime.Now;
        oldWeight.weight = weight;

        context.OldWeights.AddObject(oldWeight);

        context.SaveChanges();
    }
コード例 #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        HtmlGenericControl li = (HtmlGenericControl)this.Page.Master.FindControl("Ulnav").FindControl("liLoggedExercises");
        li.Attributes.Add("class", "active");

        user = userManager.getLimitBreaker(User.Identity.Name);
        ucViewExercise.userControlEventHappened += new EventHandler(viewExercises_userControlEventHappened);
        if (!IsPostBack)
        {
            selectedExercise = exerciseManager.getFirstExercise();
            createTextBoxes();
            displayLogs();
        }
        else
        {
            if (loggedExercises.SelectedIndex != -1)
            {
                logID = Convert.ToInt64(loggedExercises.SelectedValue);
            }
            selectedExercise = exerciseManager.getExerciseById(ucViewExercise.ddlSelectedValue);
            createTextBoxes();
        }
    }