public async Task <int> UpdateVisitSettings(VisitSettings visitSettings)
        {
            var existing = context.VisitSettings.FirstOrDefault(m => m.Id == visitSettings.Id);

            context.Entry(existing).CurrentValues.SetValues(visitSettings);
            return(await context.SaveChangesAsync());
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,WindowPeriod,VisitStage,Medication")] VisitSettings visitSettings)
        {
            if (id != visitSettings.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    await _visitSettings.UpdateVisitSettings(visitSettings);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!_visitSettings.VisitSettingsExists(visitSettings.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(visitSettings));
        }
        public async Task <IActionResult> Create([Bind("WindowPeriod,VisitStage, Medication")] VisitSettings visitSettings)
        {
            if (ModelState.IsValid)
            {
                await _visitSettings.AddVisitSettings(visitSettings);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(visitSettings));
        }
 public async Task <int> AddVisitSettings(VisitSettings visitSettings)
 {
     context.Add(visitSettings);
     return(await context.SaveChangesAsync());
 }