public List <SmartSerach_Result> SmartSearch(string freeText) { using (var context = new UniversityEntities()) { return(context.SmartSerach(freeText).ToList()); } }
public StudentEditorWindow(UniversityEntities context, Student student) { InitializeComponent(); _context = context; _student = student; birthdayPicker.SelectedDate = new DateTime(2001, 1, 1); listGenders.ItemsSource = new List <string> { "М", "Ж" }; listGroups.ItemsSource = context.Groups.ToList(); if (_student == null) { _student = new Student(); studentWasNull = true; deleteButton.Visibility = Visibility.Hidden; return; } image.Source = new BitmapImage(new Uri(student.Photo, UriKind.RelativeOrAbsolute)); nameBlock.Text = _student.Name; surnameBlock.Text = _student.Surname; birthdayPicker.Text = _student.Birthday.ToString("d"); listGenders.SelectedItem = _student.Gender; listGroups.SelectedItem = _student.Group; }
public CategoryMaster GetCategory(Decimal id) { using (var context = new UniversityEntities()) { return(context.CategoryMaster.FirstOrDefault(y => y.Id == id && y.IsDeleted != true)); } }
public List <CategoryMaster> GetCategoryMasters() { using (var context = new UniversityEntities()) { return(context.CategoryMaster.Where(y => y.IsDeleted != true).ToList()); } }
private void AddStudent(object parameter) { using (_ujc = new UniversityEntities()) { try { University_Student tmp = new University_Student(); tmp.First_Name = StudentName; tmp.Last_Name = StudentLastName; tmp.Birthday = StudentBirthdate; tmp.Email = StudentEmail; if (StudentPhoto == null) { tmp.Photo = null; } else { tmp.Photo = ImageToByte(StudentPhoto); } _ujc.University_Student.Add(tmp); _ujc.SaveChanges(); UpdateStudentsList(); CloseCommand(); } catch { } } }
//CONSTRUCTOR public GroupVM() { _deleteGroup = new Command <University_Group>(DeleteGroupFromDB, s => s != null); _editGroup = new Command <University_Group>(EditGroupFromDB, s => s != null && !string.IsNullOrWhiteSpace(GroupNameEdit)); _addNewGroup = new Command <string>(AddNewGroupToDB, s => { if (!string.IsNullOrWhiteSpace(s)) { using (_ujc = new UniversityEntities()) { var cnt = _ujc.University_Group.Where(gr => gr.Group_Name == s).ToList().Count; return(!(cnt > 0)); } } return(false); }); _addSubject = new Command <University_Subject>(AddSubjectFromList, s => SelectedGroup != null && s != null ); _removeSubject = new Command <University_Subject>(RemoveSubjectFromList, s => SelectedGroup != null && s != null); _addStudents = new Command <University_Student>(AddStudentToGroup, s => SelectedGroup != null && s != null); _removeStudents = new Command <University_Student>(RemoveStudentFromGroup, s => SelectedGroup != null && s != null); RefreshIt(); }
public IEnumerable <SubCategoryMaster> GetSubCategoryList(Decimal CategoryId) { using (var context = new UniversityEntities()) { return(context.SubCategoryMaster.Include("CategoryMaster").Where(y => y.CategoryId == CategoryId && y.IsDeleted != true).ToList()); } }
public IEnumerable <Login_tbl> GetUserList() { using (var context = new UniversityEntities()) { return(context.Login_tbl.Where(y => y.IsDeleted == false).ToList()); } }
public bool AddCategoryUserMapping(CategoryUserMapping model) { using (var context = new UniversityEntities()) { var categoryMapping = context.CategoryUserMapping.FirstOrDefault(y => y.ID == model.ID && y.IsDeleted != true); // var categoryId = context.CategoryMaster.FirstOrDefault().Id; if (categoryMapping != null) { categoryMapping.AdminID = Convert.ToInt32(HttpContext.Current.Session["AdminLoginID"]); categoryMapping.UserID = model.UserID; categoryMapping.CategoryID = model.CategoryID; categoryMapping.UpdatedDate = DateTime.UtcNow; context.SaveChanges(); } else { model.AdminID = Convert.ToInt32(HttpContext.Current.Session["AdminLoginID"]); //model.CategoryID = categoryId; model.CreatedDate = DateTime.UtcNow; model.IsDeleted = false; context.CategoryUserMapping.Add(model); context.SaveChanges(); } return(true); } }
public List <SubCategoryMaster> GetSubCategoryListById(Decimal id) { using (var context = new UniversityEntities()) { return(context.SubCategoryMaster.Where(y => y.CategoryId == id && y.IsDeleted != true).ToList()); } }
public bool AddOrUpdateSubCategory(SubCategoryMaster model) { using (var context = new UniversityEntities()) { var subcategory = context.SubCategoryMaster.FirstOrDefault(y => y.Id == model.Id && y.IsDeleted != true); var categoryId = context.CategoryMaster.FirstOrDefault().Id; if (subcategory != null) { if (!string.IsNullOrWhiteSpace(model.ImageURL)) { subcategory.ImageURL = model.ImageURL; } subcategory.AssocitedCustID = Convert.ToInt32(HttpContext.Current.Session["AdminLoginID"]); subcategory.Name = model.Name; subcategory.CategoryId = categoryId; subcategory.UpdatedDate = DateTime.UtcNow; subcategory.ImageALT = model.ImageALT; context.SaveChanges(); } else { model.AssocitedCustID = Convert.ToInt32(HttpContext.Current.Session["AdminLoginID"]); model.CategoryId = categoryId; model.CreatedDate = DateTime.UtcNow; model.IsDeleted = false; context.SubCategoryMaster.Add(model); context.SaveChanges(); } return(true); } }
public List <ProductLayoutMenu> GetProductLayouMenu() { using (var context = new UniversityEntities()) { int UserID = Convert.ToInt32(HttpContext.Current.Session["UserLoginID"]); var res = (from p in context.Product.Where(y => y.IsDeleted != true) join s in context.SubCategoryMaster.Where(y => y.IsDeleted != true) on p.SubCategoryId equals s.Id join cm in context.CategoryUserMapping.Where(y => y.IsDeleted != true) on s.Id equals cm.CategoryID join l in context.Login_tbl.Where(y => y.ID == UserID) on cm.UserID equals l.ID select new ProductLayoutMenu() { ProductId = p.Id, ProductName = p.Title, SubCategoryId = s.Id, SubCategoryName = s.Name, CategoryMappID = cm.ID, CategoryUserMappID = l.ID }).ToList(); return(res); } }
public Decimal SaveProductDocument(ProductDocuments productDocument) { using (var context = new UniversityEntities()) { var productDocumentExising = context.ProductDocuments.FirstOrDefault(y => y.Id == productDocument.Id && y.IsDeleted != true); if (productDocumentExising != null) { productDocument.AssocitedCustID = productDocument.AssocitedCustID; productDocumentExising.UpdatedDate = DateTime.UtcNow; if (!string.IsNullOrWhiteSpace(productDocument.DocumentURL)) { productDocumentExising.DocumentURL = productDocument.DocumentURL; } productDocumentExising.Decription = productDocument.Decription; productDocumentExising.DocumentDisplayName = productDocument.DocumentDisplayName; productDocumentExising.Title = productDocument.Title; context.SaveChanges(); return(productDocumentExising.Id); } else { productDocument.CreatedDate = DateTime.UtcNow; context.ProductDocuments.Add(productDocument); context.SaveChanges(); return(productDocument.Id); } } }
public List <Customer> GetCustomerList() { using (var context = new UniversityEntities()) { return(context.Customer.ToList()); } }
private void SaveNewTeacherToDB(object obj) { try { using (_ujc = new UniversityEntities()) { University_Teacher _teach = new University_Teacher(); _teach.First_Name = Tname; _teach.Last_Name = Tlname; _teach.Birthday = Tbdate; _teach.Email = Temail; if (Tphoto != null) { _teach.Photo = ImageToByte(Tphoto); } _teach.Login = Tlogin; _teach.Password = Tpwd; _ujc.University_Teacher.Add(_teach); _ujc.SaveChanges(); } } catch { } finally { EditEnabled = false; AddButtonName = "Add New..."; _addNewTeacher = new Command <object>(AddNewTeacherToDB); RaisePropertyChanged("AddNewTeacher"); BlockGrid = true; RefreshIt(); } }
public Decimal SaveProductVideo(ProductVideos productVideo) { using (var context = new UniversityEntities()) { var productVideoExising = context.ProductVideos.FirstOrDefault(y => y.Id == productVideo.Id && y.IsDeleted != true); if (productVideoExising != null) { productVideoExising.AssocitedCustID = productVideo.AssocitedCustID; productVideoExising.UpdatedDate = DateTime.UtcNow; productVideoExising.Title = productVideo.Title; productVideoExising.Decription = productVideo.Decription; if (!string.IsNullOrWhiteSpace(productVideo.VideoURL)) { productVideoExising.VideoURL = productVideo.VideoURL; } if (!string.IsNullOrWhiteSpace(productVideo.ThumbnailURL)) { productVideoExising.ThumbnailURL = productVideo.ThumbnailURL; } context.SaveChanges(); return(productVideoExising.Id); } else { productVideo.CreatedDate = DateTime.UtcNow; context.ProductVideos.Add(productVideo); context.SaveChanges(); return(productVideo.Id); } } }
private void SaveEditedTeacherToDB(University_Teacher obj) { try { using (_ujc = new UniversityEntities()) { var _teach = _ujc.University_Teacher.Where(s => s.Teacher_ID == SelectedTeacher.Teacher_ID).Single(); _teach.First_Name = Tname; _teach.Last_Name = Tlname; _teach.Birthday = Tbdate; _teach.Email = Temail; if (Tphoto != null) { _teach.Photo = ImageToByte(Tphoto); } _teach.Login = Tlogin; _teach.Password = Tpwd; _ujc.SaveChanges(); } } finally { EditEnabled = false; EditButtonName = "Edit"; _editTeacher = new Command <University_Teacher>(EditTeacherFromDB, (S) => SelectedTeacher != null); RaisePropertyChanged("EditTeacher"); AllowAddButton = true; BlockGrid = true; RefreshIt(); } }
private void UpdateStudent(object parameter) { using (_ujc = new UniversityEntities()) { //try { University_Student tmp = _ujc.University_Student.Single((st) => st.Student_ID == SelectedStudent.Student_ID); tmp.First_Name = StudentName; tmp.Last_Name = StudentLastName; tmp.Birthday = StudentBirthdate; tmp.Email = StudentEmail; if (StudentPhoto != null) { tmp.Photo = ImageToByte(StudentPhoto); } else { tmp.Photo = ImageToByte(new BitmapImage(new Uri(@"G:\Универ\GoogleDrive_oldan\Bionic Final Project\UniversityJournal\UniversityJournal\bin\Debug\no_img.jpg"))); } _ujc.SaveChanges(); UpdateStudentsList(); CloseCommand(); } //catch { } } }
public Login_tbl EditUser(int id) { using (var context = new UniversityEntities()) { return(context.Login_tbl.FirstOrDefault(x => x.ID == id)); } }
public StudentProfile(string userID) { InitializeComponent(); db = new UniversityEntities(); UserId = Convert.ToInt32(userID); gradeList = new List <int>(); }
public bool UpdateProductvideo(ProductVideos model) { using (var context = new UniversityEntities()) { var productvideo = context.ProductVideos.FirstOrDefault(y => y.Id == model.Id && y.IsDeleted != true); if (productvideo != null) { productvideo.Decription = model.Decription; productvideo.Title = model.Title; productvideo.ProductId = model.ProductId; productvideo.ThumbnailURL = model.ThumbnailURL; //productvideo.AssocitedID = model.AssocitedID; if (!string.IsNullOrWhiteSpace(model.VideoURL)) { productvideo.VideoURL = model.VideoURL; } productvideo.IsDeleted = false; productvideo.UpdatedDate = DateTime.UtcNow; context.SaveChanges(); } else { model.CreatedDate = DateTime.UtcNow; model.IsDeleted = false; context.ProductVideos.Add(model); context.SaveChanges(); } return(true); } }
public Exam(int userID, Comboitem subject) { InitializeComponent(); db = new UniversityEntities(); userId = userID; mySubject = subject; }
static void Main(string[] args) { using (var uni = new UniversityEntities()) { var x = uni.Students.ToList(); } }
public bool AddOrUpdateHomeSlider(HomeSlider model) { using (var context = new UniversityEntities()) { int AdminID = Convert.ToInt32(HttpContext.Current.Session["AdminLoginID"]); var slider = context.HomeSlider.FirstOrDefault(y => y.Id == model.Id && y.IsDeleted != true); if (slider != null) { slider.ProductId = model.ProductId; slider.AssocitedCustID = AdminID; slider.TextDescription = model.TextDescription; slider.Link = model.Link; slider.ImageALT = model.ImageALT; slider.IsDeleted = false; if (!string.IsNullOrWhiteSpace(model.ImageURL)) { slider.ImageURL = model.ImageURL; } slider.UpdatedDate = DateTime.UtcNow; context.SaveChanges(); } else { model.AssocitedCustID = AdminID; model.IsDeleted = false; model.CreatedDate = DateTime.UtcNow; context.HomeSlider.Add(model); context.SaveChanges(); } return(true); } }
public List <HomeSlider> GetHomeSliders() { using (var context = new UniversityEntities()) { return(context.HomeSlider.Include("Product").Where(y => y.IsDeleted != true).ToList()); } }
public FAQ GetFAQ(Decimal id) { using (var context = new UniversityEntities()) { return(context.FAQ.FirstOrDefault(y => y.Id == id && y.IsDeleted != true)); } }
public HomeSlider GetHomeSlider(int id) { using (var context = new UniversityEntities()) { return(context.HomeSlider.Include("Product").FirstOrDefault(y => y.Id == id && y.IsDeleted != true)); } }
//public List<SmartSerach_Result> SmartSearch(string freeText) //{ // using (var context = new IPSU_devEntities()) // { // return context.SmartSerach(freeText).ToList(); // } //} #region FAQ public IEnumerable <FAQ> GetFAQList() { using (var context = new UniversityEntities()) { int AdminID = Convert.ToInt32(HttpContext.Current.Session["AdminLoginID"]); if (AdminID != 0) { var res = context.FAQ.Where(y => y.IsDeleted == false && y.AssocitedCustID == AdminID).OrderByDescending(y => y.CreatedDate).ToList(); return(res.Select(y => new FAQ() { Id = y.Id, Question = y.Question, Answer = y.Answer, AssocitedCustID = AdminID, FAQDoc = null }).OrderByDescending(y => y.CreatedDate).ToList()); } else { int UserID = Convert.ToInt32(HttpContext.Current.Session["UserLoginID"]); var res = context.FAQ.Where(y => y.IsDeleted != true).OrderByDescending(y => y.CreatedDate).ToList(); return(res.Select(y => new FAQ() { Id = y.Id, Question = y.Question, Answer = y.Answer, //AssocitedID = y.AssocitedID, FAQDoc = null }).OrderByDescending(y => y.CreatedDate).ToList()); } } }
private void SaveStudentPresenceAndMark(University_Student obj) { using (_ujc = new UniversityEntities()) { var _StudState = _ujc.University_StudentPresence .Where(ls => ls.LessonID == SelectedLesson.Lesson_ID) .Where(st => st.StudentID == SelectedStudent.Student_ID) .Where(dt => dt.Date == LessonDate.Date).FirstOrDefault(); if (_StudState != null) { _StudState.Present = StudentPresent; _StudState.Mark = Convert.ToInt32(StudentMark); } else { University_StudentPresence tmp = new University_StudentPresence(); tmp.LessonID = SelectedLesson.Lesson_ID; tmp.StudentID = SelectedStudent.Student_ID; tmp.Date = LessonDate.Date; tmp.Present = StudentPresent; tmp.Mark = Convert.ToInt32(StudentMark); _ujc.University_StudentPresence.Add(tmp); } _ujc.SaveChanges(); SaveInfo = String.Format("Information about {0} {1} has been saved", SelectedStudent.Last_Name, SelectedStudent.First_Name); OnSelectedLessonChange(); } }
public List <ProductUserGuide> GetSearchUserGuides(string SearchTxt) { using (var context = new UniversityEntities()) { return(context.ProductUserGuide.Where(y => y.Title.Contains(SearchTxt)).ToList()); } }
public Int32 GetNumberOfStudents(String connectionString) { Int32 result = 0; var context = new UniversityEntities(); if (connectionString != null) { if (logger.IsInfoEnabled) { logger.Info("Using the following connection string: " + connectionString); } context = new UniversityEntities(connectionString); } using (context) { result = context.Students.Count(); } return result; }
public void Insert(Student student, String connectionString) { var context = new UniversityEntities(); if (connectionString != null) { if (logger.IsInfoEnabled) { logger.Info("Using the following connection string: " + connectionString); } context = new UniversityEntities(connectionString); } using (context) { if (student == null) { logger.Error("Cannot insert a null student in the database."); } else { context.Students.AddObject(student); context.SaveChanges(); } } }