Example #1
0
        /// <summary>
        /// Calculate the image for the Level.
        /// </summary>
        /// <param name="level">Level for which the image must be returned.</param>
        /// <param name="size">Size of the image.</param>
        /// <returns>Bitmap with the image corresponding to the training level.</returns>
        public static Bitmap GetLevelImage(this TrainingLevel level, ImageSize size)
        {
            Bitmap result = null;

            switch (level)
            {
            case TrainingLevel.Introductive:
                switch (size)
                {
                case ImageSize.Small:
                    result = Resources.teacher_small;
                    break;

                case ImageSize.Medium:
                    result = Resources.teacher;
                    break;

                case ImageSize.Big:
                    result = Resources.teacher_big;
                    break;
                }
                break;

            case TrainingLevel.Advanced:
                switch (size)
                {
                case ImageSize.Small:
                    result = Resources.graduate_small;
                    break;

                case ImageSize.Medium:
                    result = Resources.graduate;
                    break;

                case ImageSize.Big:
                    result = Resources.graduate_big;
                    break;
                }
                break;

            case TrainingLevel.Expert:
                switch (size)
                {
                case ImageSize.Small:
                    result = Resources.genius_small;
                    break;

                case ImageSize.Medium:
                    result = Resources.genius;
                    break;

                case ImageSize.Big:
                    result = Resources.genius_big;
                    break;
                }
                break;
            }

            return(result);
        }
Example #2
0
 public void updateTLTable(TrainingLevel tl, int id)
 {
     {
         SqlConnection con;
         SqlCommand    cmd;
         try
         {
             con = connect("DBConnectionString"); // create the connection
         }
         catch (Exception ex)
         {
             throw (ex);
         }
         String cStr = BuildInsertCommand1(tl, id);
         cmd = CreateCommand(cStr, con);
         try
         {
             int numEffected = cmd.ExecuteNonQuery(); // execute the command
         }
         catch (Exception ex)
         {
             throw (ex);
         }
         finally
         {
             if (con != null)
             {
                 con.Close();
             }
         }
     }
 }
Example #3
0
        public List <TrainingLevel> GetTrainingLevel()
        {
            List <TrainingLevel> TL  = new List <TrainingLevel>();
            SqlConnection        con = null;

            try
            {
                con = connect("DBConnectionString");
                String        selectSTR = "SELECT * FROM TrainingLevel_2020";
                SqlCommand    cmd       = new SqlCommand(selectSTR, con);
                SqlDataReader dr        = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                while (dr.Read())
                {
                    TrainingLevel trininglevel = new TrainingLevel();
                    trininglevel.Traininglevel = (string)dr["TrainingLevel"];
                    trininglevel.Id            = Convert.ToInt32(dr["TrainingLevelId"]);
                    TL.Add(trininglevel);
                }
                return(TL);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            finally
            {
                if (con != null)
                {
                    con.Close();
                }
            }
        }
Example #4
0
        private String BuildInsertCommand(TrainingLevel tl)
        {
            String command;

            String prefix = "INSERT INTO TrainingLevel_2020 (TrainingLevel)";
            String str    = "Values('" + tl.Traininglevel + "')";

            command = prefix + str;
            return(command);
        }
Example #5
0
        private String BuildInsertCommand(TrainingLevel tl, int id)
        {
            String command;

            StringBuilder sb  = new StringBuilder();
            StringBuilder sb1 = new StringBuilder();
            string        p   = id.ToString();
            string        trl = tl.Id.ToString();


            command = "UPDATE Guide_2020 SET TrainingLevelId =" + trl + " WHERE UserId =" + p;


            return(command);
        }
Example #6
0
        /// <summary>
        /// Get the lessons for a specific level.
        /// </summary>
        /// <param name="level">Level of the training.</param>
        /// <param name="requiredTags">Required tags.</param>
        /// <returns>List of Lessons for the given level and with at least one of the searched tags, if specified.</returns>
        public IEnumerable <LessonInfo> GetLessons(TrainingLevel level, IEnumerable <string> requiredTags = null)
        {
            IEnumerable <LessonInfo> result;

            if (!_trainings.TryGetValue(level, out var trainings))
            {
                trainings = null;
            }

            if ((trainings?.Any() ?? false) && requiredTags != null)
            {
                result = GetLessons(trainings, requiredTags);
            }
            else
            {
                result = trainings;
            }

            return(result);
        }
Example #7
0
 public static bool IsNull(this TrainingLevel tl)
 {
     return(tl == null);
 }
Example #8
0
 public void Save(string userName, int age, float height, float weight, float imc, int score, Complexion complexion, TrainingLevel training)
 {
     /*
      * if (isFirstTime)
      *  isFirstTime = false;
      *
      * this.userName = userName;
      * this.age = age;
      * this.height = height;
      * this.weight = weight;
      * this.imc = imc;
      * this.score = score;
      *
      * this.complexion = complexion;
      * this.training = training;
      *
      * Observer.Singleton.OnSave();
      */
 }
Example #9
0
    public void SaveTraining(TrainingLevel training)
    {
        this.training = training;

        Observer.Singleton.OnSave();
    }
Example #10
0
 // PUT api/<controller>/5
 public void Put(int id, [FromBody] TrainingLevel tl)
 {
     tl.UpdateTL(id);
 }
Example #11
0
 // POST api/<controller>
 public void Post([FromBody] TrainingLevel tl)
 {
     tl.InsertTrainingLevel();
 }
Example #12
0
        // GET api/<controller>
        public List <TrainingLevel> Get()
        {
            TrainingLevel TL = new TrainingLevel();

            return(TL.GetTrainingLevel());
        }
Example #13
0
        public static async Task <JSONTraining> ToJSONAsync(this Training training, IUnitOfWork uiOfWork)
        {
            if (training.TrainingDataId != null)
            {
                TrainingData data = await uiOfWork.TrainingDatas.GetAsync((int)training.TrainingDataId);

                if (data.IsNull())
                {
                    return(null);
                }

                ProgramType pt = await uiOfWork.ProgramTypes.GetAsync(data.ProgramTypeId);

                if (pt.IsNull())
                {
                    return(null);
                }

                TrainingLevel tl = await uiOfWork.TrainingLevels.GetAsync(data.LevelId);

                if (tl.IsNull())
                {
                    return(null);
                }

                Gym gym = await uiOfWork.Gyms.GetAsync(training.GymId);

                if (gym.IsNull())
                {
                    return(null);
                }

                CoachTraining ct =
                    await uiOfWork.CoachesTrainings.FindAsync(coachTraining => coachTraining.TrainingId == training.Id);

                if (ct.IsNull())
                {
                    return(null);
                }

                Employee empl = await uiOfWork.Employees.GetAsync(ct.CoachId);

                if (empl.IsNull())
                {
                    return(null);
                }

                JSONTraining tr = new JSONTraining
                {
                    Id         = training.Id,
                    StartTime  = training.StartTime,
                    EndTime    = training.EndTime,
                    IsFinished = training.IsFinished,
                    GymName    = gym.Name,

                    Description   = data.TrainingDescription,
                    IsMustPay     = data.IsMustPay,
                    TrainingName  = data.TrainingName,
                    IsNewTraining = data.IsNewTraining,
                    Ispopular     = data.Ispopular,

                    ProgramType = pt.Name,

                    CoachId     = empl.Id,
                    CoachName   = empl.Name,
                    CoachFamily = empl.Family,
                    LevelName   = tl.Name,
                };

                //Если это платная тренировка
                if (data is PayTraining payTraining)
                {
                    tr.PlacesCount     = payTraining.PlacesCount;
                    tr.BusyPlacesCount = training.BusyPlacesCount;
                    //tr.FreePlacesCount = payTraining.FreePlacesCount;
                }
                return(tr);
            }

            return(null);
        }
Example #14
0
        private String BuildInsertCommand1(TrainingLevel tl, int id)
        {
            string p = id.ToString();

            return("UPDATE TrainingLevel_2020 SET TrainingLevel ='" + tl.Traininglevel + "' WHERE TrainingLevelId =" + p);
        }