示例#1
0
        public MainWindow()
        {
            HealthProblem healthProblem = new HealthProblem();

            healthProblem.Name        = "Zespół przewlekłego zmęczenia";
            healthProblem.Description = "Zespół przewlekłego zmęczenia (ang. Chronic Fatigue Syndrome, CFS) obecnie jest uznawany za chorobę cywilizacyjną." +
                                        " Cierpią na nią przede wszystkim młode, aktywne kobiety, pracujące zawodowo i opiekujące się dziećmi oraz domem. Zmęczenie polega na tym," +
                                        " że uczucie wyczerpania towarzyszy przez kilka tygodni, mimo długiego wypoczynku. Chroniczne zmęczenie ogranicza aktywność człowieka o ponad 50%." +
                                        " Objawy przewlekłego zmęczenia występują zarówno u osób zdrowych, jak i cierpiących na choroby somatyczne oraz niektóre zaburzenia psychiczne.";
            healthProblem.Cause = "Jakas przyczyna";

            Suplement suplement = new Suplement();

            suplement.Name = "Ashwagandha";


            healthProblem.Suplements = new List <Suplement>(new Suplement[] { suplement, suplement });


            selectedItem = new SelectedItem();
            selectedItem.AllHealthProblems = new List <HealthProblem>(new HealthProblem[] { healthProblem });


            //TODO: DOdac obiekty



            this.DataContext = selectedItem;


            InitializeComponent();
        }
        public async Task <IActionResult> PostUserMetrics(User user, MetricsModel model, UserManager <User> _userManager)
        {
            user.Age    = model.MetricAge;
            user.Height = model.MetricHeight;
            WeightHistory        history = new WeightHistory(user.Id, model.MetricWeight, DateTime.Now.Date);
            WeightHistoryManager manager = new WeightHistoryManager(_context, _userManager);
            await manager.AddChange(history);

            user.Goal       = model.MetricGoal;
            user.MaxPushUps = model.MetricPushUps;
            user.MaxPullUps = model.MetricPullUps;
            user.IsMetrics  = true;


            for (int i = 0; i < model.MetricHealth.Count; i++)
            {
                HealthProblem problem = new HealthProblem(user.Id, model.MetricHealth[i].Problem);

                await _context.HealthProblems.AddAsync(problem);

                await _context.SaveChangesAsync();
            }


            await _userManager.UpdateAsync(user);

            return(new OkResult());
        }
示例#3
0
        static bool NeedsBackup(HealthProblem healthProblem)
        {
            switch (healthProblem.Code)
            {
            case HealthCode.Outdated:
            case HealthCode.MissingPathsFile:
            case HealthCode.BadInstallPath:
            case HealthCode.BadGamePath:
            case HealthCode.BadOutputPath:
                return(true);
            }

            return(false);
        }
示例#4
0
 public bool HealthProblemInsert(HealthProblem entity)
 {
     try
     {
         HealthProblemTable = db.GetTable <HealthProblem>();
         HealthProblemTable.InsertOnSubmit(entity);
         db.SubmitChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
示例#5
0
 public bool HealthProblemDelete(int HealthProblemID)
 {
     try
     {
         HealthProblemTable = db.GetTable <HealthProblem>();
         HealthProblem model = HealthProblemTable.SingleOrDefault(x => x.HealthProblemID.Equals(HealthProblemID));
         model.Status = false;
         db.SubmitChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
示例#6
0
        public void DataLoaderTest()
        {
            //given
            Mock <IHealthProblemsRestClient> restMock = new Mock <IHealthProblemsRestClient>();

            DataLoader dataLoader = new DataLoader((IHealthProblemsRestClient)restMock.Object);

            restMock.Setup(x => x.GetHealthProblemsJson()).Returns(@"[
                {
                ""name"": ""Problem1"",
                ""description"": ""opis1"",
                ""suplements"": [
                    {
                    ""name"": ""Suplement1"",
                    ""suplementDescription"": ""opisSupl1"",
                    ""howTo"": ""howTo1"",
                    ""linkUrl"": ""link1""
                    }]
                }]");

            //when
            SelectedItem result = dataLoader.LoadData();

            //then
            Assert.IsNull(result.SelectedHealthProblem);
            Assert.IsNull(result.SelectedSuplement);

            Assert.AreEqual(result.AllHealthProblems.Count, 1);

            HealthProblem healthProblem = result.AllHealthProblems.ElementAt(0);

            Assert.AreEqual(healthProblem.Name, "Problem1");
            Assert.AreEqual(healthProblem.Description, "opis1");
            Assert.AreEqual(healthProblem.Suplements.Count, 1);
            Assert.AreEqual(healthProblem.Suplements.ElementAt(0).Name, "Suplement1");
            Assert.AreEqual(healthProblem.Suplements.ElementAt(0).SuplementDescription, "opisSupl1");
            Assert.AreEqual(healthProblem.Suplements.ElementAt(0).LinkUrl, "link1");
            Assert.AreEqual(healthProblem.Suplements.ElementAt(0).HowTo, "howTo1");
        }
示例#7
0
        public bool HealthProblemUpdate(HealthProblem entity)
        {
            try
            {
                HealthProblemTable = db.GetTable <HealthProblem>();
                HealthProblem model = HealthProblemTable.SingleOrDefault(x => x.HealthProblemID.Equals(entity.HealthProblemID));
                model.StudentID  = entity.StudentID;
                model.StartDate  = entity.StartDate;
                model.EndDate    = entity.EndDate;
                model.Signal     = entity.Signal;
                model.Diagnosed  = entity.Diagnosed;
                model.Measure    = entity.Measure;
                model.Serverity  = entity.Serverity;
                model.EmployeeID = entity.EmployeeID;
                model.Status     = entity.Status;

                db.SubmitChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }