Ejemplo n.º 1
0
        private static (DateTime begin, DateTime end, Activiaty activity) EnterExercise()
        {
            Console.WriteLine("Введите назване упражнения:");
            var name           = Console.ReadLine();
            var energyActivity = ParseDouble("Расход энергии");
            var activity       = new Activiaty(name, energyActivity);
            var begin          = ParseDate("Начало упражнения");
            var end            = ParseDate("окончание упражнения ");

            return(begin, end, activity);
        }
Ejemplo n.º 2
0
        public void AddTest()
        {
            //Arrage
            var userName           = Guid.NewGuid().ToString();
            var activytyName       = Guid.NewGuid().ToString();
            var rnd                = new Random();
            var userController     = new UserController(userName);
            var exerciseController = new ExerciseController(userController.CurrentUser);
            var activity           = new Activiaty(activytyName, rnd.Next(50, 100));

            //Act
            exerciseController.Add(activity, DateTime.Now, DateTime.Now.AddHours(1));

            //Assert
            Assert.AreEqual(activytyName, exerciseController.Activiaties.First().Name);
        }
Ejemplo n.º 3
0
        public void Add(Activiaty activity, DateTime begin, DateTime end)
        {
            var act = Activiaties.SingleOrDefault(a => a.Name == activity.Name);

            if (act == null)
            {
                Activiaties.Add(activity);
                var exercise = new Exercise(begin, end, activity, user);
                Exercises.Add(exercise);
            }
            else
            {
                var exercise = new Exercise(begin, end, act, user);
                Exercises.Add(exercise);
            }

            Save();
        }