Пример #1
0
        /// <summary>
        /// Method for getting result of all test for athlete
        /// </summary>
        /// <param name="userId"></param>
        /// <returns>Result list</returns>
        public List <AthleteResult> GetAthleteResult(long userId)
        {
            try
            {
                List <AthleteResult> lstAthleteResult = new List <AthleteResult>();
                using (SqlConnection connection = new SqlConnection(this.conn))
                {
                    string sql = "GetAthleteResult";
                    using (SqlCommand command = new SqlCommand(sql, connection))
                    {
                        command.CommandType = CommandType.StoredProcedure;
                        command.Parameters.Add("@UserId", SqlDbType.BigInt).Value = userId;
                        connection.Open();
                        SqlDataReader reader = command.ExecuteReader();
                        while (reader.Read())
                        {
                            AthleteResult athleteResult = new AthleteResult();
                            athleteResult.UserTestId = long.Parse(reader["UserTestId"].ToString());
                            athleteResult.TestName   = reader["Name"].ToString();
                            athleteResult.Date       = Convert.ToDateTime(reader["Date"].ToString());
                            athleteResult.Score      = decimal.Parse(reader["Score"].ToString());

                            lstAthleteResult.Add(athleteResult);
                        }
                        connection.Close();
                    }
                }
                return(lstAthleteResult);
            }
            catch (Exception ex)
            {
                return(new List <AthleteResult>());
            }
        }
Пример #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            AthleteResult athleteResult = db.AthleteResults.Find(id);

            db.AthleteResults.Remove(athleteResult);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #3
0
 public ActionResult Edit([Bind(Include = "ID,AID,EID,EventDate,LID,RaceTime")] AthleteResult athleteResult)
 {
     if (ModelState.IsValid)
     {
         db.Entry(athleteResult).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(athleteResult));
 }
Пример #4
0
        public ActionResult Create([Bind(Include = "ID,AID,EID,EventDate,LID,RaceTime")] AthleteResult athleteResult)
        {
            if (ModelState.IsValid)
            {
                db.AthleteResults.Add(athleteResult);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(athleteResult));
        }
Пример #5
0
 public ActionResult Edit([Bind(Include = "AthleteResultsID,RaceTime,LocationID,AthleteID,ResultID")] AthleteResult athleteResult)
 {
     if (ModelState.IsValid)
     {
         db.Entry(athleteResult).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.AthleteID  = new SelectList(db.Athletes, "AthleteID", "Name", athleteResult.AthleteID);
     ViewBag.LocationID = new SelectList(db.Locations, "LocationID", "Location1", athleteResult.LocationID);
     ViewBag.ResultID   = new SelectList(db.Results, "ResultID", "Event", athleteResult.ResultID);
     return(View(athleteResult));
 }
Пример #6
0
        public ActionResult Create([Bind(Include = "AthleteResultsID,RaceTime,LocationID,AthleteID,ResultID")] AthleteResult athleteResult)
        {
            if (ModelState.IsValid)
            {
                db.AthleteResults.Add(athleteResult);
                db.SaveChanges();
                return(RedirectToAction("Create"));
            }

            ViewBag.AthleteID  = new SelectList(db.Athletes, "AthleteID", "Name", athleteResult.AthleteID);
            ViewBag.LocationID = new SelectList(db.Locations, "LocationID", "Location1", athleteResult.LocationID);
            ViewBag.ResultID   = new SelectList(db.Results, "ResultID", "Event", athleteResult.ResultID);
            return(View(athleteResult));
        }
Пример #7
0
        // GET: AthleteResults/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AthleteResult athleteResult = db.AthleteResults.Find(id);

            if (athleteResult == null)
            {
                return(HttpNotFound());
            }
            return(View(athleteResult));
        }
Пример #8
0
        // GET: AthleteResults/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AthleteResult athleteResult = db.AthleteResults.Find(id);

            if (athleteResult == null)
            {
                return(HttpNotFound());
            }
            ViewBag.AthleteID  = new SelectList(db.Athletes, "AthleteID", "Name", athleteResult.AthleteID);
            ViewBag.LocationID = new SelectList(db.Locations, "LocationID", "Location1", athleteResult.LocationID);
            ViewBag.ResultID   = new SelectList(db.Results, "ResultID", "Event", athleteResult.ResultID);
            return(View(athleteResult));
        }
Пример #9
0
        public ActionResult AthleteDetails(int?id)
        {
            Athlete athlete = db.Athletes.Find(id);

            var dbresults = db.AthleteResults.Where(m => m.AID == id).ToArray();

            int length = dbresults.Length;

            AthleteResult[] resultList = new AthleteResult[length];

            for (int i = 0; i < length; i++)
            {
                resultList[i] = dbresults[i];
            }

            AthleteDataViewModel model = new AthleteDataViewModel(athlete, resultList);

            return(View(model));
        }