public IActionResult Edit(int id, EditConcentrationViewModel vm)
        {
            //Make sure the model state is valid
            if (!ModelState.IsValid)
            {
                return(View("Edit", vm));
            }

            Concentration concentration;

            // If we are adding a concentration
            if (id == -1)
            {
                concentration = new Concentration
                {
                    Name = vm.Title
                };

                _context.UpdateConcentration(-1, concentration);
            }
            else //Editing a concentration
            {
                concentration = _context.ReadConcentration(id);

                concentration.Name = vm.Title;

                _context.UpdateConcentration(id, concentration);
            }

            return(RedirectToAction("Index"));
        }
        /// <summary>
        /// IAction method for returning an addition view
        /// </summary>
        /// <returns></returns>
        public IActionResult Add()
        {
            //Create view model with -1 as id to signify we are adding a concentration
            var vm = new EditConcentrationViewModel();

            vm.Id = -1;

            return(View("Edit", vm));
        }
        /// <summary>
        /// IAction method for handling returning an edit view
        /// </summary>
        /// <param name="id">Id for a concentration</param>
        /// <param name="read"></param>
        /// <returns>Handles read only instructions</returns>
        public IActionResult Edit(int id, bool read = false)
        {
            var concentration = _context.ReadConcentration(id);

            var vm = new EditConcentrationViewModel
            {
                ReadOnly = read,
                Id       = concentration.Id,
                Title    = concentration.Name
            };

            return(View(vm));
        }