Пример #1
0
        public async Task <IActionResult> Edit(int id, [Bind("EntryId,Date,Temperature,Note,Mood,Headache,Cough,Lack_of_Smell,Lack_of_Taste,Fever,Chills,Breathlessness,Fatigue,Sore_Throat,Nausea,Diarrhea,Chest_Pressure,Pale_Blue_Skin")] CovidEntry covidEntry)
        {
            if (id != covidEntry.EntryId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(covidEntry);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CovidEntryExists(covidEntry.EntryId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(covidEntry));
        }
Пример #2
0
        public async Task <IActionResult> Create([Bind("EntryId,Date,Temperature,Note,Mood,Headache,Cough,Lack_of_Smell,Lack_of_Taste,Fever,Chills,Breathlessness,Fatigue,Sore_Throat,Nausea,Diarrhea,Chest_Pressure,Pale_Blue_Skin")] CovidEntry covidEntry)
        {
            if (ModelState.IsValid)
            {
                _context.Add(covidEntry);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(covidEntry));
        }
Пример #3
0
        public static string SymptomsList(CovidEntry covidEntry)
        {
            string symptoms = "";

            foreach (var prop in covidEntry.GetType().GetProperties())
            {
                // type is the data type
                var type = Nullable.GetUnderlyingType(prop.PropertyType) ?? prop.PropertyType;
                if (type == typeof(bool))
                {
                    if ((bool)prop.GetValue(covidEntry, null) == true)
                    {
                        symptoms += prop.Name + ", ";
                    }
                }
            }
            if (symptoms.Length == 0)
            {
                return("No symptoms");
            }

            return(symptoms.Remove(symptoms.Length - 2, 2).Replace("_", " "));
        }