public static bool CreateStudent(studentprofile stuprofile) { using (var context = new AssessmentContext()) { context.Database.Connection.Open(); stuprofile.CreatedDate = DateTime.Now; stuprofile.LastModifiedDate = DateTime.Now; context.studentprofile.Add(stuprofile); context.SaveChanges(); var userexists = context.studentprofile.Select(x => x.FirstName == stuprofile.FirstName && x.LastName == stuprofile.LastName && x.DoB == stuprofile.DoB).FirstOrDefault(); return(userexists); } }
public static bool CreateKCSAssessment(KCSAssessment kcsAssessment) { using (var context = new AssessmentContext()) { context.Database.Connection.Open(); kcsAssessment.CIIndex = CIDevision(kcsAssessment); kcsAssessment.AQIIndex = AQIPoints(kcsAssessment); kcsAssessment.CreatedDate = DateTime.Now; kcsAssessment.LastModifiedDate = DateTime.Now; kcsAssessment.CreatedBy = UserValidation.FindUserId(HttpContext.Current.Session["LoginedUser"].ToString()); kcsAssessment.LastModifiedBy = UserValidation.FindUserId(HttpContext.Current.Session["LoginedUser"].ToString()); context.kcsassessment.Add(kcsAssessment); context.SaveChanges(); var userexists = context.kcsassessment.Select(x => x.AInfo5 == kcsAssessment.AInfo5 && x.AInfo6 == kcsAssessment.AInfo6).FirstOrDefault(); return(userexists); } }
public static bool ModifyStudent(studentprofile stuprofile) { using (var context = new AssessmentContext()) { try { context.Database.Connection.Open(); studentprofile studentPro = context.studentprofile.Where(x => x.iD == stuprofile.iD).First(); studentPro.FirstName = stuprofile.FirstName; studentPro.LastName = stuprofile.LastName; studentPro.DoB = stuprofile.DoB; studentPro.Emailaddress = stuprofile.Emailaddress; studentPro.LastModifiedDate = DateTime.Now; context.SaveChanges(); } catch (System.Data.Entity.Core.OptimisticConcurrencyException) { } var userexists = context.studentprofile.Select(x => x.FirstName == stuprofile.FirstName && x.LastName == stuprofile.LastName && x.DoB == stuprofile.DoB).FirstOrDefault(); return(userexists); } }