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()); } }
public ActionResult Editar(int Id) { StudentViewModel model = new StudentViewModel(); using (CollegeEntities bd = new CollegeEntities()) { var oStudent = bd.Student.Find(Id); model.Id_Student = oStudent.Id_Student; model.Name = oStudent.Name; model.Surname = oStudent.Surname; model.National_Identity_Document = oStudent.National_Identity_Document.Value; model.Docket = oStudent.Docket.Value; model.Email = oStudent.Email; model.Password = oStudent.Password; } return(View(model)); }
public ActionResult Index() { List <CourseViewModelList> Cursos; using (CollegeEntities bd = new CollegeEntities()) { Cursos = (from t in bd.Course from p in bd.Teacher where t.Id_Teacher == p.Id_Teacher select new CourseViewModelList { Id_Course = t.Id_Course, Name_Course = t.Name_Course, Time_Course = t.Time_Course.Value, // Id_Teacher= p.Id_Teacher, NombreProfesor = p.Name + " " + p.Surname, }).ToList(); } return(View(Cursos)); }
public ActionResult Editar(int Id) { CourseViewModelList model = new CourseViewModelList(); using (CollegeEntities bd = new CollegeEntities()) { var oCourse = bd.Course.Find(Id); model.Id_Course = oCourse.Id_Course; model.Name_Course = oCourse.Name_Course; model.Day = oCourse.Day; model.Time_Course = oCourse.Time_Course.Value; model.Id_Teacher = oCourse.Id_Teacher.Value; model.Maximun_Number_Of_Students = oCourse.Maximun_Number_Of_Students.Value; model.Details = oCourse.Detail; } return(View(model)); }
public static string Login(string email, string password) { HttpContext.Current.Session["USER"] = null; long enterpriseId = Convert.ToInt64(cWebCrypto.Decrypt(HttpContext.Current.Request.QueryString["ac"])); if (!string.IsNullOrEmpty(email) && !string.IsNullOrEmpty(password)) { _context = cDataContextFactory.GetDataContext(); cLogin user = _context.ACAD_USUARIOS.Where(x => x.CD_ACADEMIA == enterpriseId && x.TX_EMAIL == email && x.TX_SENHA == password && x.FL_ATIVO == true) .Select(x => new cLogin() { enterpriseId = x.CD_ACADEMIA, userId = x.CD_USUARIO, userName = x.NM_USUARIO, email = x.TX_EMAIL, teacher = x.ACAD_ACADEMIAS.ACAD_CURSOS .Where(y => y.CD_PROFESSOR == x.CD_USUARIO) .Select(y => new cTeacher() { courseId = SqlFunctions.StringConvert((double)y.CD_CURSO), couseName = y.NM_CURSO }) .ToList() }).FirstOrDefault(); if (user != null) { foreach (cTeacher item in user.teacher) { item.courseId = cWebCrypto.Encrypt(item.courseId.Trim()); } HttpContext.Current.Session["USER"] = user; return(cWebCrypto.Encrypt(user.userId.ToString())); } } return(""); }
public static bool SendContact(string name, string email, string message) { try { long enterpriseId = Convert.ToInt64(cWebCrypto.Decrypt(HttpContext.Current.Request.QueryString["ac"])); _context = cDataContextFactory.GetDataContext(); ACAD_ACADEMIAS ac = _context.ACAD_ACADEMIAS .Where(x => x.CD_ACADEMIA == enterpriseId).FirstOrDefault(); if (!string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(email) && !string.IsNullOrEmpty(message)) { cEmail cemail = new cEmail() { UrlBase = ac.TX_URL_BASE, Url = ac.TX_URL, ServerSmtp = ac.TX_SMTP, PortSmtp = ac.TX_SMTP_PORTA, UserSmtp = ac.TX_EMAIL, PasswordSmtp = ac.TX_SENHA_EMAIL, NameTo = ac.NM_ACADEMIA, EmailTo = ac.TX_EMAIL, NameFrom = name, EmailFrom = ac.TX_EMAIL, NameReply = name, EmailReply = email, ContactMessage = message }; if (SendEmail(cemail, cEnum.TypeFile.EmailContact)) { return(true); } ; } } catch { } return(false); }
public ActionResult Index() { List <CourseViewModelList> Cursos; using (CollegeEntities bd = new CollegeEntities()) { Cursos = (from t in bd.Course select new CourseViewModelList { Id_Course = t.Id_Course, Name_Course = t.Name_Course, Time_Course = t.Time_Course.Value, Day = t.Day, Id_Teacher = t.Id_Teacher.Value, Maximun_Number_Of_Students = t.Maximun_Number_Of_Students.Value, Details = t.Detail, }).ToList(); } return(View(Cursos)); }
public ActionResult Index() { List <StudentViewModel> Students; using (CollegeEntities bd = new CollegeEntities()) { Students = (from t in bd.Student where t.IdFamilia == 1 select new StudentViewModel { Id_Student = t.Id_Student, Name = t.Name, Surname = t.Surname, National_Identity_Document = t.National_Identity_Document.Value, Docket = t.Docket.Value, Email = t.Email, Password = t.Password, }).ToList(); } return(View(Students)); }
public static bool Forgot(cEmail cEmail) { try { long enterpriseId = Convert.ToInt64(cWebCrypto.Decrypt(HttpContext.Current.Request.QueryString["ac"])); _context = cDataContextFactory.GetDataContext(); ACAD_USUARIOS user = _context.ACAD_USUARIOS.Include("ACAD_ACADEMIAS") .Where(x => x.CD_ACADEMIA == enterpriseId && x.TX_EMAIL == cEmail.EmailTo && x.FL_ATIVO == true).FirstOrDefault(); if (user != null) { cEmail.UrlBase = user.ACAD_ACADEMIAS.TX_URL_BASE; cEmail.Url = user.ACAD_ACADEMIAS.TX_URL; cEmail.ForgotPassword = user.TX_SENHA; cEmail.ServerSmtp = user.ACAD_ACADEMIAS.TX_SMTP; cEmail.PortSmtp = user.ACAD_ACADEMIAS.TX_SMTP_PORTA; cEmail.UserSmtp = user.ACAD_ACADEMIAS.TX_EMAIL; cEmail.PasswordSmtp = user.ACAD_ACADEMIAS.TX_SENHA_EMAIL; cEmail.NameTo = user.NM_USUARIO; cEmail.EmailTo = user.TX_EMAIL; cEmail.NameFrom = user.ACAD_ACADEMIAS.NM_ACADEMIA; cEmail.EmailFrom = user.ACAD_ACADEMIAS.TX_EMAIL; if (SendEmail(cEmail, cEnum.TypeFile.EmailForgotPassword)) { return(true); } ; } } catch { } return(false); }
public static User Authorization(string login, string password, CollegeEntities db) { return(db.Users.FirstOrDefault(u => u.ID == db.Logins_and_passwords.FirstOrDefault(lap => lap.Password == password && lap.Login == login).ID_User)); }
public cBusinessWeb(long enterpriseId) { _context = cDataContextFactory.GetDataContext(); _enterpriseId = enterpriseId; }