Exemple #1
0
 private void WriteRecord(ExerciseRecord record)
 {
     record.MemberId = int.Parse(Session["memberId"].ToString());
     record.Running  = float.Parse(Request["running"]);
     record.PushUp   = int.Parse(Request["pushup"]);
     record.SitUp    = int.Parse(Request["situp"]);
     record.Reading  = int.Parse(Request["reading"]);
     if (record.Write())
     {
         List <object> list = new List <object>()
         {
             new
             {
                 IsWrite = true
             }
         };
         Response.Write(Helper.GetResponseJson(list));
     }
     else
     {
         List <object> list = new List <object>()
         {
             new
             {
                 IsWrite = false,
                 Content = "Cannot record down"
             }
         };
         Response.Write(Helper.GetResponseJson(list));
     }
 }
Exemple #2
0
        public async Task <ExerciseRecord> Add(ExerciseRecord exerciseRecord, Guid exerciseSessionId)
        {
            using (var session = _graphRepository.Driver.Session())
            {
                var reader = await session.RunAsync(
                    @"MATCH (es:ExerciseSession { id: $exerciseSessionId })
                    CREATE (er:ExerciseRecord { id: $id, epochTimestamp: $epochTimestamp, set: $set, reps: $reps, value: $value, unit: $unit, dropSet: $dropSet, note: $note }),
                    (er)-[:FOR_EXERCISE_SESSION]->(es)
                    RETURN er.id, er.epochTimestamp, er.set, er.reps, er.value, er.unit, er.dropSet, er.note",
                    new
                {
                    exerciseSessionId = exerciseSessionId,
                    id             = exerciseRecord.Id.ToString(),
                    epochTimestamp = exerciseRecord.EpochTimestamp,
                    set            = exerciseRecord.Set,
                    reps           = exerciseRecord.Reps,
                    value          = exerciseRecord.Value,
                    unit           = exerciseRecord.Unit,
                    dropSet        = exerciseRecord.DropSet,
                    note           = exerciseRecord.Note
                }
                    );

                exerciseRecord = await GetExerciseRecord(reader);
            }
            return(exerciseRecord);
        }
Exemple #3
0
    private void ReadRecord(ExerciseRecord record)
    {
        record.MemberId = int.Parse(Session["memberId"].ToString());
        var result = record.ReadForHomeDisplay();

        Response.Write(Helper.GetResponseJson(result));
    }
Exemple #4
0
    private void ReadFriendRecord(ExerciseRecord record)
    {
        record.MemberId = int.Parse(Request["friendId"]);
        var result = record.ReadForHomeDisplay();

        Response.Write(Helper.GetResponseJson(result));
    }
Exemple #5
0
    private void ReadFriendLastWeekTotal(ExerciseRecord record)
    {
        record.MemberId = int.Parse(Request["friendId"]);
        var result = record.ReadTotalForLastWeek();

        Response.Write(Helper.GetResponseJson(result));
    }
Exemple #6
0
    private void ReadMyLastWeekTotal(ExerciseRecord record)
    {
        record.MemberId = int.Parse(Session["memberId"].ToString());
        var result = record.ReadTotalForLastWeek();

        Response.Write(Helper.GetResponseJson(result));
    }
Exemple #7
0
        public async Task <JsonResult> CreateNewExerciseRecord(string exercise, double?weightQuantity, double?distanceQuantity, double?timeQuantity, double?repsQuantity, DateTime submitDate)
        {
            Exercise e = await _context.Exercise
                         .FromSqlInterpolated($"SELECT * FROM Exercise WHERE Name={exercise}")
                         .FirstOrDefaultAsync();

            ExerciseRecord er = new ExerciseRecord()
            {
                Exercise         = e,
                ExcerciseID      = e.ExerciseID,
                UserID           = User.Claims.First().Value,
                WeightQuantity   = weightQuantity,
                DistanceQuantity = distanceQuantity,
                TimeQuantity     = timeQuantity,
                RepQuantity      = repsQuantity,
                SubmitDate       = submitDate
            };

            _context.Add(er);
            await _context.SaveChangesAsync();

            return(Json(new
            {
                success = false
            }));
        }
Exemple #8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string         action = Request["action"];
        ExerciseRecord record = new ExerciseRecord();

        if (action == "write")
        {
            WriteRecord(record);
        }
        if (action == "readForHomeDisplay")
        {
            ReadRecord(record);
        }
        if (action == "readFirendsRecord")
        {
            ReadFriendRecord(record);
        }
        if (action == "readMyLastWeekTotal")
        {
            ReadMyLastWeekTotal(record);
        }
        if (action == "readFriendLastWeekTotal")
        {
            ReadFriendLastWeekTotal(record);
        }
    }
Exemple #9
0
        public async Task <ExerciseRecord> Update(ExerciseRecord exerciseRecord)
        {
            using (var session = _graphRepository.Driver.Session())
            {
                var reader = await session.RunAsync(
                    @"MATCH (er:ExerciseRecord { id: $id }) 
                    SET 
                    er.epochTimestamp = $epochTimestamp, 
                    er.set = $set, 
                    er.reps = $reps, 
                    er.value = $value, 
                    er.unit = $unit, 
                    er.dropSet = $dropSet, 
                    er.note = $note 
                    RETURN er.id, er.epochTimestamp, er.set, er.reps, er.value, er.unit, er.dropSet, er.note",
                    new
                {
                    id             = exerciseRecord.Id.ToString(),
                    epochTimestamp = exerciseRecord.EpochTimestamp,
                    set            = exerciseRecord.Set,
                    reps           = exerciseRecord.Reps,
                    value          = exerciseRecord.Value,
                    unit           = exerciseRecord.Unit,
                    dropSet        = exerciseRecord.DropSet,
                    note           = exerciseRecord.Note
                }
                    );

                exerciseRecord = await GetExerciseRecord(reader);
            }
            return(exerciseRecord);
        }
Exemple #10
0
        public ActionResult DeleteConfirmed(int id)
        {
            ExerciseRecord exerciseRecord = db.ExerciseRecords.Find(id);

            db.ExerciseRecords.Remove(exerciseRecord);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #11
0
 public ActionResult Add(ExerciseRecord obj)
 {
     using (DBModel db = new DBModel())
     {
         db.ExerciseRecords.Add(obj);
         db.SaveChanges();
         return(Json(new { success = true, message = "Saved Successfully" }, JsonRequestBehavior.AllowGet));
     }
 }
Exemple #12
0
 public ActionResult Edit(ExerciseRecord obj)
 {
     using (DBModel db = new DBModel())
     {
         db.Entry(obj).State = EntityState.Modified;
         db.SaveChanges();
         return(Json(new { success = true, message = "Updated Successfully" }, JsonRequestBehavior.AllowGet));
     }
 }
Exemple #13
0
        public async Task <ActionResult> DeleteConfirmed(long id)
        {
            ExerciseRecord exerciseRecord = await db.ExerciseRecords.FindAsync(id);

            db.ExerciseRecords.Remove(exerciseRecord);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Exemple #14
0
 public ActionResult Delete(int id)
 {
     using (DBModel db = new DBModel())
     {
         ExerciseRecord obj = db.ExerciseRecords.Where(x => x.Id == id).FirstOrDefault <ExerciseRecord>();
         db.ExerciseRecords.Remove(obj);
         db.SaveChanges();
         return(Json(new { success = true, message = "Deleted Successfully" }, JsonRequestBehavior.AllowGet));
     }
 }
Exemple #15
0
        // GET: ExerciseRecords/Create
        public ActionResult Create()
        {
            ViewBag.ExerciseId = new SelectList(db.Exercises.Where(o => o.Set.AspNetUser.Id.ToLower().CompareTo(user.Id.ToLower()) == 0), "Id", "Name");
            var model = new ExerciseRecord();

            model.Date      = DateTime.Now;
            model.StartDate = DateTime.Now;
            model.EndDate   = DateTime.Now;
            model.Record    = 0;
            return(View(model));
        }
Exemple #16
0
 public ActionResult Edit([Bind(Include = "ExerciseRecordId,ComplexReps,ComplexSets,LiftWeight,RunSpeed,RunTime,RunDistance,ExerciseID,AthleteID")] ExerciseRecord exerciseRecord)
 {
     if (ModelState.IsValid)
     {
         db.Entry(exerciseRecord).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.AthleteID  = new SelectList(db.Athletes, "ID", "Sex", exerciseRecord.AthleteID);
     ViewBag.ExerciseID = new SelectList(db.Exercises, "ID", "Name", exerciseRecord.ExerciseID);
     return(View(exerciseRecord));
 }
Exemple #17
0
        public static ChartExerciseRecord PopulateChartExerciseRecord(ExerciseRecord exerciseRecord, IEnumerable <int> monthsInSetsData, IEnumerable <int> weeksInSetsData, DateTime startDate, DateTime endDate)
        {
            ChartExerciseRecord chartExerciseRecord = new ChartExerciseRecord();

            chartExerciseRecord.Id        = exerciseRecord.Id;
            chartExerciseRecord.Record    = (float)exerciseRecord.Record;
            chartExerciseRecord.StartDate = exerciseRecord.StartDate;
            chartExerciseRecord.EndDate   = exerciseRecord.EndDate;
            chartExerciseRecord.Date      = exerciseRecord.Date;

            return(chartExerciseRecord);
        }
Exemple #18
0
        public async Task <ActionResult> Edit([Bind(Include = "Id,Record,Date,StartDate,EndDate,ExerciseId")] ExerciseRecord exerciseRecord)
        {
            if (ModelState.IsValid)
            {
                db.Entry(exerciseRecord).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.ExerciseId = new SelectList(db.Exercises.Where(o => o.Set.AspNetUser.Id.ToLower().CompareTo(user.Id.ToLower()) == 0), "Id", "Name", exerciseRecord.ExerciseId);
            return(View(exerciseRecord));
        }
Exemple #19
0
        // GET: ExerciseRecords/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ExerciseRecord exerciseRecord = db.ExerciseRecords.Find(id);

            if (exerciseRecord == null)
            {
                return(HttpNotFound());
            }
            return(View(exerciseRecord));
        }
Exemple #20
0
        // GET: ExerciseRecords/Details/5
        public async Task <ActionResult> Details(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ExerciseRecord exerciseRecord = await db.ExerciseRecords.FindAsync(id);

            if (exerciseRecord == null)
            {
                return(HttpNotFound());
            }
            return(View(exerciseRecord));
        }
Exemple #21
0
        // GET: ExerciseRecords/Edit/5
        public async Task <ActionResult> Edit(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ExerciseRecord exerciseRecord = await db.ExerciseRecords.FindAsync(id);

            if (exerciseRecord == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ExerciseId = new SelectList(db.Exercises.Where(o => o.Set.AspNetUser.Id.ToLower().CompareTo(user.Id.ToLower()) == 0), "Id", "Name", exerciseRecord.ExerciseId);
            return(View(exerciseRecord));
        }
Exemple #22
0
        public async Task <IHttpActionResult> PostExerciseRecord(ExerciseRecord exerciseRecord)
        {
            await HubGateway.GetInstance().IsDataUpdateRequiredForWeb(user.Email, true, "Create exercise record operation");

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.ExerciseRecords.Add(exerciseRecord);
            await db.SaveChangesAsync();


            return(CreatedAtRoute("DefaultApi", new { id = exerciseRecord.Id }, exerciseRecord));
        }
Exemple #23
0
        public async Task <IHttpActionResult> GetExerciseRecord(long id)
        {
            ExerciseRecord exerciseRecord = await db.ExerciseRecords.FindAsync(id);

            if (exerciseRecord.Exercise.Set.AspNetUser.Id.ToLower().CompareTo(user.Id.ToLower()) != 0)
            {
                exerciseRecord = null;
            }

            if (exerciseRecord == null)
            {
                return(NotFound());
            }

            return(Ok(exerciseRecord));
        }
Exemple #24
0
        // GET: ExerciseRecords/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ExerciseRecord exerciseRecord = db.ExerciseRecords.Find(id);

            if (exerciseRecord == null)
            {
                return(HttpNotFound());
            }
            ViewBag.AthleteID  = new SelectList(db.Athletes, "ID", "Sex", exerciseRecord.AthleteID);
            ViewBag.ExerciseID = new SelectList(db.Exercises, "ID", "Name", exerciseRecord.ExerciseID);
            return(View(exerciseRecord));
        }
        public void SaveUserActivityRecord(int setRowID, int excerciseRowID, double record)
        {
            var set         = this.userSetsData[setRowID];
            var excercise   = set.Exercises[excerciseRowID];
            var newExercise = new ExerciseRecord()
            {
                StartDate = DateTime.Now, EndDate = DateTime.Now, Date = DateTime.Now, ExerciseId = long.Parse(excercise.ID), Record = record
            };
            var newExerciseAsJSON         = JsonConvert.SerializeObject(newExercise);
            var saveRecordServiceResults  = this.webApiHelper.PostAsJSON(this.serviceAPIURL + "/ExerciseRecords", newExerciseAsJSON);
            var NewExerciseFromServerData = JsonConvert.DeserializeObject <ExerciseRecord>(saveRecordServiceResults);

            //TODO: Check for response status OK or FAILED
            this.signalRClient.IsDataUpdateRequiredForWeb(this.LoginData.UserEMail, true, "New data from iOS client. UI update required on Web App.");
            //this.userSetsData [setRowID].Exercises.Add (NewExerciseFromServerData);
        }
        public ActionResult Index([Bind(Include = "ExerciseRecordId, LiftWeight, ExerciseID, AthleteID")] ExerciseRecord exerciseRecord)
        {
            string id   = User.Identity.GetUserId();
            Person temp = db.Persons.FirstOrDefault(p => p.ASPNetIdentityID == id);

            if (ModelState.IsValid)
            {
                exerciseRecord.AthleteID = temp.ID;
                db.ExerciseRecords.Add(exerciseRecord);
                db.SaveChanges();
                return(RedirectToAction("Index", "Home", new { area = "Athlete" }));
            }

            ViewBag.ExerciseID = new SelectList(db.Exercises, "ID", "Name", exerciseRecord.ExerciseID);
            return(RedirectToAction("Index", "Home", new { area = "Athlete" }));
        }
Exemple #27
0
        private void ParseOutExcercise()
        {
            string excercise = this.ParseOutExcerciseNote("E:");

            if (excercise.isNullOrEmpty())
            {
                excercise = this.ParseOutExcerciseNote("e:");
            }

            if (!excercise.isNullOrEmpty())
            {
                this._exercise = new ExerciseRecord()
                {
                    ExcerciseNote = excercise, PersonId = _personId
                };
            }
        }
Exemple #28
0
        public ActionResult Create(string ExerciseName, DateTime ExerciseDate, int DurationInMinutes)
        {
            try
            {
                ExerciseRecord collection = new ExerciseRecord();

                collection.ExerciseName      = ExerciseName;
                collection.ExerciseDate      = ExerciseDate;
                collection.DurationInMinutes = DurationInMinutes;

                interfaceObj.InsertExerciseRecord(collection);
                interfaceObj.Save();

                return(RedirectToAction("Index"));
            }
            catch (Exception)
            {
                return(View());
            }
        }
Exemple #29
0
        private async Task <ExerciseRecord> GetExerciseRecord(IStatementResultCursor reader)
        {
            ExerciseRecord item = null;

            while (await reader.FetchAsync())
            {
                item = new ExerciseRecord()
                {
                    Id             = Guid.Parse(reader.Current[0].ToString()),
                    EpochTimestamp = double.Parse(reader.Current[1].ToString()),
                    Set            = reader.Current[2].ToString(),
                    Reps           = (Int64)reader.Current[3],
                    Value          = double.Parse(reader.Current[4].ToString()),
                    Unit           = reader.Current[5]?.ToString(),
                    DropSet        = (bool)reader.Current[6],
                    Note           = reader.Current[7]?.ToString()
                };
            }
            return(item);
        }
Exemple #30
0
        public async Task <IHttpActionResult> DeleteExerciseRecord(long id)
        {
            await HubGateway.GetInstance().IsDataUpdateRequiredForWeb(user.Email, true, "Delete exercise record operation");

            ExerciseRecord exerciseRecord = await db.ExerciseRecords.FindAsync(id);

            if (exerciseRecord.Exercise.Set.AspNetUser.Id.ToLower().CompareTo(user.Id.ToLower()) != 0)
            {
                exerciseRecord = null;
            }

            if (exerciseRecord == null)
            {
                return(NotFound());
            }

            db.ExerciseRecords.Remove(exerciseRecord);
            await db.SaveChangesAsync();

            return(Ok(exerciseRecord));
        }
        public static ChartExerciseRecord PopulateChartExerciseRecord(ExerciseRecord exerciseRecord, IEnumerable<int> monthsInSetsData, IEnumerable<int> weeksInSetsData, DateTime startDate, DateTime endDate)
        {
            ChartExerciseRecord chartExerciseRecord = new ChartExerciseRecord();

            chartExerciseRecord.Id = exerciseRecord.Id;
            chartExerciseRecord.Record = (float)exerciseRecord.Record;
            chartExerciseRecord.StartDate = exerciseRecord.StartDate;
            chartExerciseRecord.EndDate = exerciseRecord.EndDate;
            chartExerciseRecord.Date = exerciseRecord.Date;

            return (chartExerciseRecord);
        }