Exemplo n.º 1
0
        public bool Update(TEntity model)
        {
            var entry = Context.Entry(model);

            DbSet.Attach(model);

            entry.State = EntityState.Modified;

            return(this.Save() > 0);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> PutAdmin(int id, Admin admin)
        {
            if (id != admin.AdminId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        public async Task <IActionResult> PutScheduler([FromRoute] int id, [FromBody] Scheduler scheduler)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != scheduler.SchedulerId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
 public ActionResult Edit([Bind(Include = "CursoId,NomeCurso,DescricaoCurso,DataICurso,DataFCurso")] Curso curso)
 {
     if (ModelState.IsValid)
     {
         db.Entry(curso).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(curso));
 }
 public ActionResult Edit([Bind(Include = "AlunoId,Nome,Email,Idade")] Aluno aluno)
 {
     if (ModelState.IsValid)
     {
         db.Entry(aluno).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(aluno));
 }
Exemplo n.º 6
0
        public virtual int Update(TObject TObject)
        {
            var entry = Context.Entry(TObject);

            DbSet.Attach(TObject);
            entry.State = EntityState.Modified;
            if (!shareContext)
            {
                return(Context.SaveChanges());
            }
            return(0);
        }
Exemplo n.º 7
0
        public async Task <ActionResult> Edit([Bind(Include = "Id,HourId,DayOfWeekId,GroupId,TeacherId,AuditoriumId,WeekId,LastChange,IsFinal,SubjectId,SubjectTypeId,SemesterId")] Schedule schedule)
        {
            if (ModelState.IsValid)
            {
                db.Entry(schedule).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.AuditoriumId  = new SelectList(db.Auditoriums, "Id", "Name", schedule.AuditoriumId);
            ViewBag.DayOfWeekId   = new SelectList(db.DayOfWeeks, "Id", "Name", schedule.DayOfWeekId);
            ViewBag.GroupId       = new SelectList(db.Groups, "Id", "Name", schedule.GroupId);
            ViewBag.HourId        = new SelectList(db.Hours, "Id", "Id", schedule.HourId);
            ViewBag.SemesterId    = new SelectList(db.Semesters, "Id", "Name", schedule.SemesterId);
            ViewBag.SubjectId     = new SelectList(db.Subjects, "Id", "Name", schedule.SubjectId);
            ViewBag.SubjectTypeId = new SelectList(db.SubjectTypes, "Id", "Name", schedule.SubjectTypeId);
            ViewBag.TeacherId     = new SelectList(db.Teachers, "Id", "FirstName", schedule.TeacherId);
            ViewBag.WeekId        = new SelectList(db.Weeks, "Id", "Id", schedule.WeekId);
            return(View(schedule));
        }