Beispiel #1
0
 public ActionResult Edit([Bind(Include = "MemberID,MemberName,MemberEmail,MemberPassword,ConfirmPassword,MemberPhone,MemberType,TutorImage,ImageMimeType,TutorPortfolio,TutorGit")] Member member)
 {
     if (ModelState.IsValid)
     {
         db.Entry(member).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(member));
 }
Beispiel #2
0
        public ActionResult Edit([Bind(Include = "LectureID,LectureTitle,LectureLanguage,LectureImage,LectureImageName,LectureImageType,TutorIntroduce,LectureIntroduce,LecturePeople,LecturePlan,LectureCount,LecturePrice,LectureMaxperson,LectureApplyDeadline,LectureLocation,LecturePlace,ScheduleTime,MemberID")] Lecture lecture, HttpPostedFileBase image = null)
        {
            if (ModelState.IsValid)
            {
                if (image != null)
                {
                    string pic  = System.IO.Path.GetFileName(image.FileName);
                    string path = System.IO.Path.Combine(
                        Server.MapPath("~/Images/"), pic);

                    image.SaveAs(path);
                    lecture.LectureImageName = image.FileName; // 파일명
                    lecture.LectureImageType = image.ContentType;

                    lecture.LectureImage = new byte[image.ContentLength];


                    image.InputStream.Read(lecture.LectureImage, 0, image.ContentLength);
                }
                db.Entry(lecture).State = EntityState.Modified;

                db.SaveChanges();

                return(RedirectToAction("Index"));
            }


            return(View(lecture));
        }
Beispiel #3
0
        public IHttpActionResult PutClass(int id, Class @class)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != @class.Id)
            {
                return(BadRequest());
            }

            db.Entry(@class).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ClassExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        //-------------------------upDate---------------------------------
        //será em feito em sites e web API (aplicações desconectadas)
        private static void updateAppDisconected()
        {
            Course course;

            //aqui é feito a conexão quando entra no app para o usuairo conseguir mexer
            //e selecionado o que irá ser mandado para o usuario
            using (var context = new ClassContext())
            {
                context.Database.Log = Console.WriteLine;
                course = context.Course.FirstOrDefault();
            }
            //depois fecha a conexao e o usuario na pagina pode editar algo
            // durante sua conexao
            course.AuthorId = 1;

            //depois é preciso salvar todas as alterações que foram feitas
            using (var context = new ClassContext())
            {
                context.Database.Log = Console.WriteLine;
                //context.Course.Attach(course); - campo não obrigatório, porém serve para avisar para ter atenção nesse objeto

                //para fazer o update é preciso pegar o objeto e dizer qual o estado dele para poder salvar
                context.Entry(course).State = EntityState.Modified;
                context.SaveChanges();//salva as alterações
            }
        }
Beispiel #5
0
 public void Delete(Classandgrade classandgrade)
 {
     using (var db = new ClassContext())
     {
         db.Entry(classandgrade).State = EntityState.Deleted;
         db.SaveChanges();
     }
 }
Beispiel #6
0
        public void Delete(ClassName blog)
        {
            using (var db = new ClassContext())
            {
                db.Entry(blog).State = EntityState.Deleted;

                db.SaveChanges();
            }
        }
Beispiel #7
0
 //根据ID删除
 public void Delete(Clas clas)
 {
     using (var db = new ClassContext())
     {
         //修改博客实体状态
         db.Entry(clas).State = EntityState.Deleted;
         db.SaveChanges();
     }
 }
Beispiel #8
0
 public void Update(ClassName blog)
 {
     using (var db = new ClassContext())
     {
         //修改博客实体状态
         db.Entry(blog).State = EntityState.Modified;
         //保存状态
         db.SaveChanges();
     }
 }
 public ActionResult Edit([Bind(Include = "AID,Name,DOB")] Athlete athlete)
 {
     if (ModelState.IsValid)
     {
         db.Entry(athlete).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(athlete));
 }
Beispiel #10
0
 public ActionResult Edit([Bind(Include = "StudentID,firstName,lastName,email")] Student student)
 {
     if (ModelState.IsValid)
     {
         db.Entry(student).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(student));
 }
Beispiel #11
0
 public ActionResult Edit([Bind(Include = "ApplicationID,ApplicationLevel,LectureID,MemberID")] Application application)
 {
     if (ModelState.IsValid)
     {
         db.Entry(application).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.LectureID = new SelectList(db.Lectures, "LectureID", "LectureTitle", application.LectureID);
     return(View(application));
 }
        public async Task <IActionResult> PutPlan(int id, PlanAcciones item)
        {
            if (id != item.IdPlanAcciones)
            {
                return(BadRequest());
            }
            _context.Entry(item).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(NoContent());
        }
        public async Task <IActionResult> PutActicidadesAsignadas(int id, ActividadAsignada item)
        {
            if (id != item.idActividad)
            {
                return(BadRequest());
            }
            _context.Entry(item).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(NoContent());
        }
Beispiel #14
0
        public async Task <IActionResult> PutAcciones(int cod_Accion, AccionesItem item)
        {
            if (cod_Accion != item.cod_Accion)
            {
                return(BadRequest());
            }
            _context.Entry(item).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(NoContent());
        }
Beispiel #15
0
 public ActionResult Edit([Bind(Include = "CurrentClassOfferingID,CID,Quarter,Year,timeOffered")] CurrentClassOffering currentClassOffering)
 {
     if (ModelState.IsValid)
     {
         db.Entry(currentClassOffering).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CID = new SelectList(db.ClassOfferings, "ClassOfferingID", "CourseCode", currentClassOffering.CID);
     return(View(currentClassOffering));
 }
        public async Task <IActionResult> PutDocente(string identificacion, DocenteItem item)
        {
            if (identificacion != item.identificacion)
            {
                return(BadRequest());
            }
            _context.Entry(item).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(NoContent());
        }
Beispiel #17
0
 public ActionResult Edit([Bind(Include = "LicenseID,LicenseName,LicenseAgency,LicenseAcqDate,LicenseNumber,MemberID")] License license)
 {
     if (ModelState.IsValid)
     {
         db.Entry(license).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.MemberID = new SelectList(db.Members, "MemberID", "MemberName", license.MemberID);
     return(View(license));
 }
Beispiel #18
0
 public ActionResult Edit([Bind(Include = "ReviewID,ReviewContent,ReviewGrade,LectureID,MemberID")] Review review)
 {
     if (ModelState.IsValid)
     {
         db.Entry(review).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.LectureID = new SelectList(db.Lectures, "LectureID", "LectureTitle", review.LectureID);
     return(View(review));
 }
Beispiel #19
0
 public ActionResult Edit([Bind(Include = "ApplyScheduleID,ApplyDayofweek,ApplyScheduleTime,ApplicationID")] ApplySchedule applySchedule)
 {
     if (ModelState.IsValid)
     {
         db.Entry(applySchedule).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ApplicationID = new SelectList(db.Applications, "ApplicationID", "ApplicationLevel", applySchedule.ApplicationID);
     return(View(applySchedule));
 }
Beispiel #20
0
        public ActionResult DeleteClass(int id, string newName, string newDepart)
        {
            Class C = cc.ClassList.Where(c => c.class_id == id).FirstOrDefault();

            C.class_name   = newName;
            C.class_depart = newDepart;
            cc.ClassList.Attach(C);
            cc.Entry(C).State = System.Data.EntityState.Modified;
            cc.SaveChanges();
            return(RedirectToAction("ManageClassPage", "Head"));
        }
Beispiel #21
0
 public void Update(Clas clas)
 {
     //设置上下文生存期
     using (var db = new ClassContext())
     {
         //用枚举来表示修改状态
         db.Entry(clas).State = EntityState.Modified;
         //保存状态改变
         db.SaveChanges();
     }
 }
Beispiel #22
0
        public async Task <IActionResult> PutTipoActividad(int cod_TipoActividad, TipoActividad item)
        {
            if (cod_TipoActividad != item.cod_TipoActividad)
            {
                return(BadRequest());
            }
            _context.Entry(item).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(NoContent());
        }
        public async Task <ActionResult> Edit([Bind(Include = "Id,Nome,Turno,Ano")] Turma turma)
        {
            if (ModelState.IsValid)
            {
                db.Entry(turma).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(turma));
        }
Beispiel #24
0
        public async Task <ActionResult> Edit([Bind(Include = "ProfessorId,Nome")] Professor professor)
        {
            if (ModelState.IsValid)
            {
                db.Entry(professor).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(professor));
        }
 public ActionResult Edit([Bind(Include = "ClassesTakenID,StudentID,CID,GPA")] ClassesTaken classesTaken)
 {
     if (ModelState.IsValid)
     {
         db.Entry(classesTaken).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CID       = new SelectList(db.CurrentClassOfferings, "CurrentClassOfferingID", "timeOffered", classesTaken.CID);
     ViewBag.StudentID = new SelectList(db.Students, "StudentID", "firstName", classesTaken.StudentID);
     return(View(classesTaken));
 }
        public async Task <ActionResult> Edit([Bind(Include = "AlunoId,Nome,TurmaId")] Aluno aluno)
        {
            if (ModelState.IsValid)
            {
                db.Entry(aluno).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.TurmaId = new SelectList(db.Turmas, "Id", "Nome", aluno.TurmaId);
            return(View(aluno));
        }
Beispiel #27
0
        public async Task <ActionResult> Edit([Bind(Include = "DisciplinaId,Nome,ProfessorId")] Disciplina disciplina)
        {
            if (ModelState.IsValid)
            {
                db.Entry(disciplina).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.ProfessorId = new SelectList(db.Professores, "ProfessorId", "Nome", disciplina.ProfessorId);
            return(View(disciplina));
        }
Beispiel #28
0
        public ActionResult Edit(StudentViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    Student dbStudent = db.Students.Find(model.StudentId);

                    if (dbStudent == null)
                    {
                        return(HttpNotFound());
                    }

                    var updatedStudent = new Student
                    {
                        StudentId  = model.StudentId,
                        FirstName  = model.FirstName,
                        LastName   = model.LastName,
                        EMail      = model.EMail,
                        Phone      = model.Phone,
                        ParentName = model.ParentName,
                        Address    = model.Address,
                        Grade      = model.Grade,
                    };

                    db.Entry(dbStudent).CurrentValues.SetValues(updatedStudent);
                    AddOrUpdateCourses(dbStudent, model.Courses);
                    db.SaveChanges();

                    return(RedirectToAction("Index"));
                }
            }
            catch (RetryLimitExceededException /* dex */)
            {
                //Log the error (uncomment dex variable name and add a line here to write a log.)
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
            }

            return(RedirectToAction("Index"));
        }
        public ActionResult Grades(GradeViewModel model)
        {
            if (ModelState.IsValid)
            {
                foreach (Grade grade in model.Grades)
                {
                    Grade oldGrade = db.Grades.Find(grade.GradeId);
                    db.Entry(oldGrade).CurrentValues.SetValues(grade);
                }
                db.SaveChanges();

                return(RedirectToAction("Details", new { id = model.CourseId }));
            }
            return(View(model));
        }
        private static void deleteCourseAppRealDisconected()
        {
            Course course;

            //primeiro a busca do que desejo remover
            using (var context = new ClassContext())
            {
                context.Database.Log = Console.WriteLine;
                course = context.Course.FirstOrDefault();
            }
            //aqui faz a remoção
            using (var context = new ClassContext())
            {
                context.Database.Log        = Console.WriteLine;
                context.Entry(course).State = EntityState.Deleted;
                context.SaveChanges();
            }
        }