Example #1
0
        public async Task <IActionResult> Edit(int id, [Bind("UserId,StudyId")] UserStudy userStudy)
        {
            if (id != userStudy.UserId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(userStudy);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UserStudyExists(userStudy.UserId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["StudyId"] = new SelectList(_context.Study, "Id", "Information", userStudy.StudyId);
            ViewData["UserId"]  = new SelectList(_context.User, "Id", "Mail", userStudy.UserId);
            return(View(userStudy));
        }
Example #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Text,IsCorrect")] Option option)
        {
            if (id != option.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(option);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OptionExists(option.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(option));
        }
Example #3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,UserName,Password,Mail")] User user)
        {
            if (id != user.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(user);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UserExists(user.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(user));
        }
Example #4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,CorrectAnswer,Questions,NumOfOptions")] Question question)
        {
            if (id != question.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(question);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!QuestionExists(question.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(question));
        }
Example #5
0
 public async Task <IActionResult> Edit(int id, [Bind("Id,Subject,Information")] Study study)
 {
     if (id != study.Id)
     {
         return(NotFound());
     }
     //var s = await _context.Study.Include(x => x.Question).ThenInclude(x => x.Options).FirstOrDefaultAsync(m => m.Id == id);
     if (ModelState.IsValid)
     {
         try
         {
             _context.Update(study);
             await _context.SaveChangesAsync();
         }
         catch (DbUpdateConcurrencyException)
         {
             if (!StudyExists(study.Id))
             {
                 return(NotFound());
             }
             else
             {
                 throw;
             }
         }
         return(View(study));
     }
     return(View(study));
 }
Example #6
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,UserName,Mobile,Mail,Subject,Message")] Contact contact)
        {
            if (id != contact.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(contact);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ContactExists(contact.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(contact));
        }