Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Content,SecretCode")] 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));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Content")] Answer answer)
        {
            if (id != answer.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(answer);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AnswerExists(answer.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(answer));
        }
Exemplo n.º 3
0
 public void SaveBranch(Branch branch)
 {
     using (var dbContext = new HRDbContext())
     {
         if (branch.ID > 0)
         {
             dbContext.Update <Branch>(branch);
         }
         else
         {
             dbContext.Insert <Branch>(branch);
         }
     }
 }
Exemplo n.º 4
0
 public void SaveStaff(Staff staff)
 {
     using (var dbContext = new HRDbContext())
     {
         if (staff.ID > 0)
         {
             dbContext.Update <Staff>(staff);
         }
         else
         {
             dbContext.Insert <Staff>(staff);
         }
     }
 }
Exemplo n.º 5
0
 public virtual T Update(T entity)
 {
     return(context.Update(entity).Entity);
 }