Example #1
0
        public async Task <IActionResult> EditProgressBar(string id, EditGoalDto goalDto)
        {
            if (id != goalDto.GoalId)
            {
                return(BadRequest());
            }

            var progressBar = await _context.ProgressBars.FindAsync(id);

            progressBar.Text      = goalDto.Text;
            progressBar.UpdatedAt = DateTime.Now;

            _context.Entry(progressBar).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProgressBarExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> EditCheckBox(string id, EditGoalDto goalDto)
        {
            if (id != goalDto.GoalId)
            {
                return(BadRequest());
            }

            var checkbox = await _context.CheckBoxes.FindAsync(id);

            checkbox.Text      = goalDto.Text;
            checkbox.UpdatedAt = DateTime.Now;

            _context.Entry(checkbox).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CheckBoxExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }