Beispiel #1
0
        public static bool AjaxSendCode(string code, string enrollment, string course)
        {
            try
            {
                long courseId     = Convert.ToInt64(cWebCrypto.Decrypt(course));
                long enrollmentId = Convert.ToInt64(cWebCrypto.Decrypt(enrollment));
                long userId       = GetLogged().userId;
                _context = cDataContextFactory.GetDataContext();

                Guid         guidCode = new Guid(code);
                ACAD_CODIGOS cod      = _context.ACAD_CODIGOS.Where(x => x.CD_CURSO == courseId &&
                                                                    x.CD_CODIGO == guidCode &&
                                                                    x.FL_ATIVO == true && x.DT_DATA == null).FirstOrDefault();
                if (cod != null)
                {
                    cod.DT_DATA = DateTime.Now;
                    _context.Entry(cod).State = System.Data.Entity.EntityState.Modified;
                    _context.SaveChanges();

                    ACAD_MATRICULAS enroll = _context.ACAD_MATRICULAS.Where(x => x.CD_CURSO == courseId &&
                                                                            x.CD_USUARIO == userId &&
                                                                            x.CD_MATRICULA == enrollmentId)
                                             .FirstOrDefault();
                    if (enroll != null)
                    {
                        enroll.TX_CODIGO             = code;
                        _context.Entry(enroll).State = System.Data.Entity.EntityState.Modified;
                        _context.SaveChanges();
                        return(true);
                    }
                }
            }
            catch { }
            return(false);
        }
Beispiel #2
0
        public static bool AjaxSetEnrollment()
        {
            try
            {
                long userId   = GetLogged().userId;
                long courseId = Convert.ToInt64(cWebCrypto.Decrypt(HttpContext.Current.Request.QueryString["c"]));
                _context = cDataContextFactory.GetDataContext();

                ACAD_MATRICULAS enrollment = _context.ACAD_MATRICULAS.Where(x => x.CD_CURSO == courseId &&
                                                                            x.CD_USUARIO == userId).FirstOrDefault();
                if (enrollment == null)
                {
                    ACAD_MATRICULAS enroll = new ACAD_MATRICULAS()
                    {
                        CD_USUARIO = userId,
                        CD_CURSO   = courseId,
                        DT_DATA    = DateTime.Now
                    };
                    _context.Entry(enroll).State = System.Data.Entity.EntityState.Added;
                    _context.SaveChanges();

                    List <ACAD_BLOCOS> blocks = _context.ACAD_BLOCOS.Where(x => x.ACAD_MODULOS.CD_CURSO == courseId).ToList();

                    foreach (ACAD_BLOCOS block in blocks)
                    {
                        ACAD_USUARIOS_BLOCOS userBlocks = new ACAD_USUARIOS_BLOCOS()
                        {
                            CD_BLOCO   = block.CD_BLOCO,
                            CD_USUARIO = userId
                        };
                        _context.Entry(userBlocks).State = System.Data.Entity.EntityState.Added;

                        List <ACAD_EXERCICIOS> exercises = _context.ACAD_EXERCICIOS.Where(x => x.CD_BLOCO == block.CD_BLOCO).ToList();

                        foreach (ACAD_EXERCICIOS item in exercises)
                        {
                            ACAD_USUARIOS_EXERCICIOS userExercise = new ACAD_USUARIOS_EXERCICIOS()
                            {
                                CD_EXERCICIO    = item.CD_EXERCICIO,
                                CD_USUARIO      = userId,
                                CD_MATRICULA    = enroll.CD_MATRICULA,
                                TX_PERGUNTA     = item.TX_PERGUNTA,
                                TX_OBS_CORRECAO = item.TX_GABARITO,
                                DT_EXERCICIO    = DateTime.Now
                            };
                            _context.Entry(userExercise).State = System.Data.Entity.EntityState.Added;
                        }
                        _context.SaveChanges();
                    }
                    return(true);
                }
            }
            catch { }
            return(false);
        }
Beispiel #3
0
        public ActionResult Create([Bind(Include = "Id,Nome")] College college)
        {
            if (ModelState.IsValid)
            {
                db.College.Add(college);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(college));
        }
Beispiel #4
0
        public ActionResult Create([Bind(Include = "Did,DName,HOD")] Dept dept)
        {
            if (ModelState.IsValid)
            {
                db.Depts.Add(dept);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(dept));
        }
Beispiel #5
0
        public ActionResult Create([Bind(Include = "Eid,EName,Salary,Dob,Gender,DeptDid")] Emp emp)
        {
            if (ModelState.IsValid)
            {
                db.Emps.Add(emp);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.DeptDid = new SelectList(db.Depts, "Did", "DName", emp.DeptDid);
            return(View(emp));
        }
Beispiel #6
0
        public ActionResult Editar(StudentViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (CollegeEntities bd = new CollegeEntities())
                    {
                        var oStudent = bd.Student.Find(model.Id_Student);

                        oStudent.Name    = model.Name;
                        oStudent.Surname = model.Surname;
                        oStudent.National_Identity_Document = model.National_Identity_Document;
                        oStudent.Docket   = model.Docket;
                        oStudent.Email    = model.Email;
                        oStudent.Password = model.Password;


                        bd.Entry(oStudent).State = System.Data.Entity.EntityState.Modified;
                        bd.SaveChanges();
                    }
                    return(Redirect("~/Student/Index"));
                }

                return(View(model));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return(View());
        }
Beispiel #7
0
        public ActionResult Nuevo(TeacherViewModelAlta model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (CollegeEntities bd = new CollegeEntities())
                    {
                        var oTeacher = new Teacher();

                        oTeacher.Name    = model.Name;
                        oTeacher.Surname = model.Surname;
                        oTeacher.National_Identity_Document = model.National_Identity_Document;
                        oTeacher.Status = model.Status;


                        bd.Teacher.Add(oTeacher);
                        bd.SaveChanges();
                    }
                    return(Redirect("~/Teacher/Index"));
                }

                return(View(model));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return(View());
        }
Beispiel #8
0
        public ActionResult Editar(TeacherViewModelAlta model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (CollegeEntities bd = new CollegeEntities())
                    {
                        var oTeacher = bd.Teacher.Find(model.Id_Teacher);

                        oTeacher.Name    = model.Name;
                        oTeacher.Surname = model.Surname;
                        oTeacher.National_Identity_Document = model.National_Identity_Document;
                        oTeacher.Status = model.Status;


                        bd.Entry(oTeacher).State = System.Data.Entity.EntityState.Modified;
                        bd.SaveChanges();
                    }
                    return(Redirect("~/Teacher/Index"));
                }

                return(View(model));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return(View());
        }
Beispiel #9
0
        public ActionResult Nuevo(CourseViewModelList model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (CollegeEntities bd = new CollegeEntities())
                    {
                        var oCourse = new Course();

                        oCourse.Name_Course = model.Name_Course;
                        oCourse.Time_Course = model.Time_Course;
                        oCourse.Day         = model.Day;
                        oCourse.Id_Teacher  = model.Id_Teacher;
                        oCourse.Maximun_Number_Of_Students = model.Maximun_Number_Of_Students;
                        oCourse.Detail = model.Details;


                        bd.Course.Add(oCourse);
                        bd.SaveChanges();
                    }


                    return(Redirect("~/Course/Index"));
                }

                return(View(model));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return(View());
        }
Beispiel #10
0
        public ActionResult Inscripcion(int Id)
        {
            oUsuario = (Student)HttpContext.Session["Usuario"];

            InscripcionViewModel model = new InscripcionViewModel();


            using (CollegeEntities bd = new CollegeEntities())
            {
                var    materia         = bd.Course.Find(Id);
                Course curso           = materia;
                var    CountInscriptos = (from m in bd.Course_Student
                                          where m.Id_Course == curso.Id_Course

                                          select m.Id_Course).ToList();
                int Inscriptos = CountInscriptos.Count();

                if (Inscriptos < materia.Maximun_Number_Of_Students)
                {
                    var OInscripcion = new Course_Student();

                    OInscripcion.Id_Course  = materia.Id_Course;
                    OInscripcion.Id_Student = oUsuario.Id_Student;

                    bd.Course_Student.Add(OInscripcion);
                    bd.SaveChanges();

                    return(RedirectToAction("Index", new { message = "se inscribio correctamente" }));
                }
                else
                {
                    return(RedirectToAction("Index", new { message = "cupo completo" }));
                }
            }
        }
Beispiel #11
0
        public ActionResult Nuevo(StudentViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (CollegeEntities bd = new CollegeEntities())
                    {
                        var oStudent = new Student();

                        oStudent.Name    = model.Name;
                        oStudent.Surname = model.Surname;
                        oStudent.National_Identity_Document = model.National_Identity_Document;
                        oStudent.Docket    = model.Docket;
                        oStudent.Email     = model.Email;
                        oStudent.Password  = model.Password;
                        oStudent.IdFamilia = 1;
                        bd.Student.Add(oStudent);
                        bd.SaveChanges();
                    }
                    return(Redirect("~/Student/Index"));
                }

                return(View(model));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return(View());
        }
Beispiel #12
0
        public ActionResult Editar(CourseViewModelList model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (CollegeEntities bd = new CollegeEntities())
                    {
                        var oCourse = bd.Course.Find(model.Id_Course);

                        oCourse.Id_Course   = model.Id_Course;
                        oCourse.Name_Course = model.Name_Course;
                        oCourse.Day         = model.Day;
                        oCourse.Time_Course = model.Time_Course;
                        oCourse.Id_Teacher  = model.Id_Teacher;
                        oCourse.Maximun_Number_Of_Students = model.Maximun_Number_Of_Students;


                        bd.Entry(oCourse).State = System.Data.Entity.EntityState.Modified;
                        bd.SaveChanges();
                    }
                    return(Redirect("~/Course/Index"));
                }

                return(View(model));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return(View());
        }
Beispiel #13
0
        public void deleterecord(int Id)
        {
            var alldata = GetStudents();
            var data    = alldata.Where(x => x.stuid == Id).FirstOrDefault();

            context.students.Remove(data);
            context.SaveChanges();
        }
Beispiel #14
0
 public String CreateTeacher(TeacherMst TeacherMst)
 {
     try
     {
         db.TeacherMsts.Add(TeacherMst);
         db.SaveChanges();
         return("0");
     }
     catch (Exception ex)
     {
         return("1");
     }
     finally
     {
         db.Dispose();
     }
 }
 public String CreateDep(DepMst objMst)
 {
     try
     {
         db.DepMsts.Add(objMst);
         db.SaveChanges();
         return("0");
     }
     catch (Exception ex)
     {
         return("1");
     }
     finally
     {
         db.Dispose();
     }
 }
Beispiel #16
0
 public String CreateEnroll(Enrollment objMst)
 {
     try
     {
         db.Enrollments.Add(objMst);
         db.SaveChanges();
         return("0");
     }
     catch (Exception ex)
     {
         return("1");
     }
     finally
     {
         db.Dispose();
     }
 }
Beispiel #17
0
 public String CreateMapp(TeacherCollegeMapp objMst)
 {
     try
     {
         db.TeacherCollegeMapps.Add(objMst);
         db.SaveChanges();
         return("0");
     }
     catch (Exception ex)
     {
         return("1");
     }
     finally
     {
         db.Dispose();
     }
 }
Beispiel #18
0
        public ActionResult Eliminar(int Id)
        {
            using (CollegeEntities bd = new CollegeEntities())
            {
                var oStudent = bd.Student.Find(Id);
                bd.Student.Remove(oStudent);
                bd.SaveChanges();
            }

            return(Redirect("~/Student/Index"));
        }
Beispiel #19
0
        public ActionResult Eliminar(int Id)
        {
            using (CollegeEntities bd = new CollegeEntities())
            {
                var oTeacher = bd.Teacher.Find(Id);
                bd.Teacher.Remove(oTeacher);
                bd.SaveChanges();
            }

            return(Redirect("~/Teacher/Index"));
        }
Beispiel #20
0
        public ActionResult create()
        {
            CollegeEntities db = new CollegeEntities();
            User            a  = new User()
            {
                Username = "******", Password = "******", GroupName = "viewer"
            };

            db.Users.Add(a);
            db.SaveChanges();
            return(Content("success"));
        }
Beispiel #21
0
        public static string SetUser(cUser cUser)
        {
            long enterpriseId = Convert.ToInt64(cWebCrypto.Decrypt(HttpContext.Current.Request.QueryString["ac"]));
            long userId       = GetLogged().userId;

            _context = cDataContextFactory.GetDataContext();

            if (_context.ACAD_USUARIOS.Where(x => x.CD_ACADEMIA == enterpriseId &&
                                             x.TX_EMAIL == cUser.email &&
                                             (userId == 0 || x.CD_USUARIO != userId)).Count() > 0)
            {
                return("-1");
            }
            ACAD_USUARIOS user = new ACAD_USUARIOS();

            if (userId > 0)
            {
                user = _context.ACAD_USUARIOS.Where(x => x.CD_USUARIO == userId).FirstOrDefault();
            }

            user.CD_ACADEMIA  = enterpriseId;
            user.NM_USUARIO   = cUser.name;
            user.NM_SOBRENOME = cUser.surname;
            user.TX_EMAIL     = cUser.email;
            user.TX_TELEFONE  = cUser.tel;
            user.TX_CELULAR   = cUser.cel;
            user.TX_CPF       = cUser.cpf;
            if (!string.IsNullOrEmpty(cUser.password))
            {
                user.TX_SENHA = cUser.password;
            }
            user.TX_IP    = cUser.ip;
            user.FL_ATIVO = true;

            if (userId == 0)
            {
                user.DT_DATA = DateTime.Now;
                _context.Entry(user).State = System.Data.Entity.EntityState.Added;
            }
            else
            {
                _context.Entry(user).State = System.Data.Entity.EntityState.Modified;
            }
            _context.SaveChanges();

            return(cWebCrypto.Encrypt(user.CD_USUARIO.ToString()));
        }
        public ActionResult Edit(int id, Student student)
        {
            try
            {
                using (CollegeEntities dbModel = new CollegeEntities())
                {
                    dbModel.Entry(student).State = EntityState.Modified;
                    dbModel.SaveChanges();
                }

                // TODO: Add update logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult Create(Student student)
        {
            try
            {
                using (CollegeEntities dbModel = new CollegeEntities())
                {
                    dbModel.Students.Add(student);
                    dbModel.SaveChanges();
                }

                // TODO: Add insert logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                using (CollegeEntities dbModel = new CollegeEntities())
                {
                    Student student = dbModel.Students.Where(x => x.Id == id).FirstOrDefault();
                    dbModel.Students.Remove(student);
                    dbModel.SaveChanges();
                }

                // TODO: Add delete logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #25
0
 protected void SaveChanges()
 {
     context.SaveChanges();
 }