Ejemplo n.º 1
0
        //public ViewEquipmentMember GetEquipmentPhotoPath(int id)
        //{
        //    ViewEquipmentMember equip = new ViewEquipmentMember();

        //    try
        //    {
        //        using (SqlConnection conn = new SqlConnection(connectionString))
        //        {
        //            conn.Open();
        //            SqlCommand cmd = new SqlCommand("Select photo_path From gym_equipment WHERE id = @id ", conn);
        //            cmd.Parameters.AddWithValue("@id", id);

        //            SqlDataReader reader = cmd.ExecuteReader();

        //            while (reader.Read())
        //            {
        //                equip = MapRowToEquipment(reader);
        //            }

        //            return equip;
        //        }
        //    }
        //    catch (SqlException ex)
        //    {
        //        throw;
        //    }
        //}

        public bool AddGymUsage(GymUsageModel model)
        {
            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand("INSERT INTO gym_equipment_usage (equipment_id, member_id, date_time, reps, weight) " +
                                                    "VALUES (@equipment_id, @member_id, @date_time, @reps, @weight)", conn);
                    cmd.Parameters.AddWithValue("@equipment_id", model.Equipment_id);
                    cmd.Parameters.AddWithValue("@member_id", model.Member_id);
                    cmd.Parameters.AddWithValue("@date_time", model.Date_time);
                    cmd.Parameters.AddWithValue("@reps", model.Reps);
                    cmd.Parameters.AddWithValue("@weight", model.Weight);
                    cmd.ExecuteNonQuery();

                    return(true);
                }
            }
            catch (SqlException ex)
            {
                return(false);

                throw;
            }
        }
Ejemplo n.º 2
0
        public IActionResult SetMemberEquipmentUsage(GymUsageModel model)
        {
            if (ModelState.IsValid)
            {
                gymDAL.AddGymUsage(model);
            }

            return(RedirectToAction(nameof(ViewEquipmentMember)));
        }
Ejemplo n.º 3
0
        public IActionResult SetMemberEquipmentUsage(int id)
        {
            GymUsageModel model       = new GymUsageModel();
            User          currentUser = authProvider.GetCurrentUser();

            model.Member_id    = currentUser.Id;
            model.Equipment_id = id;
            model.Date_time    = DateTime.Today;
            return(View(model));
        }