public List <Issue> GetAllData(int displayLength, int displayStart, int sortCol, string sortDir, string search = null) { using (var _LMContext = new LMContext()) { string columnNameAsc = ""; string columnNameDsc = ""; List <Issue> issues = new List <Issue>(); if (sortCol == 0 && sortDir == "asc") { columnNameAsc = "BookID"; } else if (sortCol == 0 && sortDir == "dsc") { columnNameDsc = "BookID"; } else if (sortCol == 1 && sortDir == "asc") { columnNameAsc = "IssueDate"; } else if (sortCol == 1 && sortDir == "dsc") { columnNameDsc = "IssueDate"; } else if (sortCol == 1 && sortDir == "asc") { columnNameAsc = "ExpiraryDate"; } else if (sortCol == 1 && sortDir == "dsc") { columnNameDsc = "ExpiraryDate"; } else if (sortCol == 1 && sortDir == "asc") { columnNameAsc = "StudentID"; } else if (sortCol == 1 && sortDir == "dsc") { columnNameDsc = "StudentID"; } if (sortDir == "asc" && string.IsNullOrEmpty(search) == false) { issues = _LMContext.Issues.OrderBy(x => columnNameAsc).Where(x => x.Books.BookName.ToString().ToLower().Contains(search.ToLower()) || x.IssueDate.ToString().ToLower().Contains(search.ToLower()) || x.ExpiraryDate.ToString().ToLower().Contains(search.ToLower()) || x.Students.Name.ToString().ToLower().Contains(search.ToLower())).Include(y => y.Students).Include(z => z.Books.Categories).Include(z => z.Books.BookPictures.Select(y => y.Pictures)).Include(z => z.Students.StudentPictures).Include(z => z.Students.Departments).ToList(); } else if (sortDir == "dsc" && string.IsNullOrEmpty(search) == false) { issues = _LMContext.Issues.OrderBy(x => columnNameDsc).Where(x => x.Books.BookName.ToString().ToLower().Contains(search.ToLower()) || x.IssueDate.ToString().ToLower().Contains(search.ToLower()) || x.ExpiraryDate.ToString().ToLower().Contains(search.ToLower()) || x.Students.Name.ToString().ToLower().Contains(search.ToLower())).Include(y => y.Students).Include(z => z.Books).Include(z => z.Books.Categories).Include(z => z.Books.BookPictures.Select(y => y.Pictures)).Include(z => z.Students.StudentPictures).Include(z => z.Students.Departments).ToList(); } else if (sortDir == "asc") { issues = _LMContext.Issues.OrderBy(x => columnNameAsc).Include(y => y.Students).Include(z => z.Books).Include(z => z.Books.Categories).Include(z => z.Books.BookPictures.Select(y => y.Pictures)).Include(z => z.Students.StudentPictures).Include(z => z.Students.Departments).ToList(); } else { issues = _LMContext.Issues.OrderBy(x => columnNameDsc).Include(y => y.Students).Include(z => z.Books).Include(z => z.Books.Categories).Include(z => z.Books.BookPictures.Select(y => y.Pictures)).Include(z => z.Students.StudentPictures).Include(z => z.Students.Departments).ToList(); } return(issues); } }
public override Staff GetDataById(int id) { using (var _LMContext = new LMContext()) { return(_LMContext.Staffs.Where(x => x.ID == id).Include(y => y.StaffPictures.Select(x => x.Pictures)).Include(w => w.Designations).FirstOrDefault()); } }
public override List <Book> GetAllData() { using (var _LMContext = new LMContext()) { return(_LMContext.Books.Where(x => x.BookQty > 0).Include(y => y.BookPictures.Select(x => x.Pictures)).ToList()); } }
public override Student GetDataById(int id) { using (var _LMContext = new LMContext()) { return(_LMContext.Students.Where(x => x.ID == id).Include(y => y.StudentPictures.Select(x => x.Pictures)).Include(w => w.Departments).FirstOrDefault()); } }
public override Return GetDataById(int id) { using (var _LMContext = new LMContext()) { return(_LMContext.Returns.Where(x => x.ID == id).Include(y => y.Books).Include(w => w.Students).Include(x => x.Staffs).FirstOrDefault()); } }
public virtual int TotalRowCount() { using (var _LMContext = new LMContext()) { return(_LMContext.Set <T>().Count()); } }
public virtual T GetDataById(int id) { using (var _LMContext = new LMContext()) { return(_LMContext.Set <T>().Find(id)); } }
public override Book GetDataById(int id) { using (var _LMContext = new LMContext()) { return(_LMContext.Books.Where(x => x.ID == id).Include(y => y.BookPictures.Select(x => x.Pictures)).FirstOrDefault()); } }
public virtual List <T> GetAllData() { using (var _LMContext = new LMContext()) { return(_LMContext.Set <T>().ToList()); } }
public virtual bool UpdateData(T model) { using (var _LMContext = new LMContext()) { _LMContext.Entry(model).State = System.Data.Entity.EntityState.Modified; return(_LMContext.SaveChanges() > 0); } }
public virtual bool SaveData(T model) { using (var _LMContext = new LMContext()) { _LMContext.Set <T>().Add(model); return(_LMContext.SaveChanges() > 0); } }
public override Issue GetDataById(int id) { using (var _LMContext = new LMContext()) { return(_LMContext.Issues.Where(x => x.ID == id).Include(y => y.Books).Include(w => w.Students).FirstOrDefault()); //return _LMContext.Issues.SqlQuery("Select * from Issues where ID ="+id).FirstOrDefault(); } }
public virtual bool DeleteData(int id) { using (var _LMContext = new LMContext()) { var designation = _LMContext.Set <T>().Find(id); _LMContext.Entry(designation).State = System.Data.Entity.EntityState.Modified; _LMContext.Set <T>().Remove(designation); return(_LMContext.SaveChanges() > 0); } }
public override bool UpdateData(Book model) { using (var _LMContext = new LMContext()) { var existingBook = _LMContext.Books.Find(model.ID); _LMContext.BookPictures.RemoveRange(existingBook.BookPictures); _LMContext.Entry(existingBook).CurrentValues.SetValues(model); _LMContext.BookPictures.AddRange(model.BookPictures); return(_LMContext.SaveChanges() > 0); } }
public override bool UpdateData(Student model) { using (var _LMContext = new LMContext()) { var existingStudent = _LMContext.Students.Find(model.ID); _LMContext.StudentPictures.RemoveRange(existingStudent.StudentPictures); _LMContext.Entry(existingStudent).CurrentValues.SetValues(model); _LMContext.StudentPictures.AddRange(model.StudentPictures); return(_LMContext.SaveChanges() > 0); } }
public override bool SaveData(Issue model) { using (var _LMContext = new LMContext()) { int bookId = model.BookID; int bookQty = _LMContext.Books.Where(x => x.ID == bookId).Select(x => x.BookQty).FirstOrDefault(); bookQty -= 1; var book = _IBookService.GetDataById(bookId); book.BookQty = bookQty; _IBookService.UpdateData(book); var value = base.SaveData(model); return(value); } }
public static string ImeRadnika() { using (var context = new LMContext()) { string UserName = System.Web.HttpContext.Current.User.Identity.Name; UserName = UserName.Replace("LANACO\\", ""); var UserID = context.Users.FirstOrDefault(m => m.UserName == UserName).UserID; var RadnikID = context.RadnikUsers.FirstOrDefault(m => m.UserID == UserID).RadnikID; var ImeRadnika = context.RadnikUsers.Where(r => r.RadnikID == RadnikID).Select(r => new { ImeIPrezime = r.Radnik.Ime + " " + r.Radnik.Prezime }).ToList(); string Ime = Convert.ToString(ImeRadnika[0].ImeIPrezime); return(Ime); } }
public List <Designation> GetAllData(int displayLength, int displayStart, int sortCol, string sortDir, string search = null) { using (var _LMContext = new LMContext()) { string columnNameAsc = ""; string columnNameDsc = ""; List <Designation> categories = new List <Designation>(); if (sortCol == 0 && sortDir == "asc") { columnNameAsc = "Name"; } else if (sortCol == 0 && sortDir == "dsc") { columnNameDsc = "Name"; } else if (sortCol == 1 && sortDir == "asc") { columnNameAsc = "Description"; } else if (sortCol == 1 && sortDir == "dsc") { columnNameDsc = "Description"; } if (sortDir == "asc" && string.IsNullOrEmpty(search) == false) { categories = _LMContext.Designations.OrderBy(x => columnNameAsc).Where(x => x.Name.ToString().ToLower().Contains(search.ToLower())).ToList(); } else if (sortDir == "dsc" && string.IsNullOrEmpty(search) == false) { categories = _LMContext.Designations.OrderBy(x => columnNameDsc).Where(x => x.Name.ToString().ToLower().Contains(search.ToLower())).ToList(); } else if (sortDir == "asc") { categories = _LMContext.Designations.OrderBy(x => columnNameAsc).ToList(); } else { categories = _LMContext.Designations.OrderBy(x => columnNameDsc).ToList(); } return(categories); } }
public List <Student> GetAllData(int displayLength, int displayStart, int sortCol, string sortDir, string search) { using (var _LMContext = new LMContext()) { string columnNameAsc = ""; string columnNameDsc = ""; List <Student> Students = new List <Student>(); if (sortCol == 0 && sortDir == "asc") { columnNameAsc = "Name"; } else if (sortCol == 0 && sortDir == "dsc") { columnNameDsc = "Name"; } else if (sortCol == 1 && sortDir == "asc") { columnNameAsc = "Code"; } else if (sortCol == 1 && sortDir == "dsc") { columnNameDsc = "Code"; } else if (sortCol == 2 && sortDir == "asc") { columnNameAsc = "Semester"; } else if (sortCol == 2 && sortDir == "dsc") { columnNameDsc = "Semester"; } else if (sortCol == 3 && sortDir == "asc") { columnNameAsc = "Gender"; } else if (sortCol == 3 && sortDir == "dsc") { columnNameDsc = "Gender"; } else if (sortCol == 4 && sortDir == "asc") { columnNameAsc = "Address"; } else if (sortCol == 4 && sortDir == "dsc") { columnNameDsc = "Address"; } else if (sortCol == 5 && sortDir == "asc") { columnNameAsc = "City"; } else if (sortCol == 5 && sortDir == "dsc") { columnNameDsc = "City"; } else if (sortCol == 6 && sortDir == "asc") { columnNameAsc = "Phone"; } else if (sortCol == 6 && sortDir == "dsc") { columnNameDsc = "Phone"; } if (sortDir == "asc" && string.IsNullOrEmpty(search) == false) { Students = _LMContext.Students.OrderBy(x => columnNameAsc).Where(x => x.Name.ToString().ToLower().Contains(search.ToLower()) || x.Code.ToString().ToLower().Contains(search.ToLower()) || x.Semester.ToString().ToLower().Contains(search.ToLower()) || x.Gender.ToString().ToLower().Contains(search.ToLower()) || x.Email.ToString().ToLower().Contains(search.ToLower()) || x.Address.ToString().ToLower().Contains(search.ToLower()) || x.City.ToString().ToLower().Contains(search.ToLower()) || x.Phone.ToString().ToLower().Contains(search.ToLower())).Include(y => y.StudentPictures.Select(x => x.Pictures)).Include(w => w.Departments).ToList(); } else if (sortDir == "dsc" && string.IsNullOrEmpty(search) == false) { Students = _LMContext.Students.OrderBy(x => columnNameDsc).Where(x => x.Name.ToString().ToLower().Contains(search.ToLower()) || x.Code.ToString().ToLower().Contains(search.ToLower()) || x.Semester.ToString().ToLower().Contains(search.ToLower()) || x.Gender.ToString().ToLower().Contains(search.ToLower()) || x.Email.ToString().ToLower().Contains(search.ToLower()) || x.Address.ToString().ToLower().Contains(search.ToLower()) || x.City.ToString().ToLower().Contains(search.ToLower()) || x.Phone.ToString().ToLower().Contains(search.ToLower())).Include(y => y.StudentPictures.Select(x => x.Pictures)).Include(w => w.Departments).ToList(); } else if (sortDir == "asc") { Students = _LMContext.Students.OrderBy(x => columnNameAsc).Include(y => y.StudentPictures.Select(x => x.Pictures)).Include(w => w.Departments).ToList(); } else { Students = _LMContext.Students.OrderBy(x => columnNameDsc).Include(y => y.StudentPictures.Select(x => x.Pictures)).Include(w => w.Departments).ToList(); } return(Students); } }
public List <Book> GetAllData(int displayLength, int displayStart, int sortCol, string sortDir, string search) { using (var _LMContext = new LMContext()) { string columnNameAsc = ""; string columnNameDsc = ""; List <Book> books = new List <Book>(); if (sortCol == 0 && sortDir == "asc") { columnNameAsc = "BookName"; } else if (sortCol == 0 && sortDir == "dsc") { columnNameDsc = "BookName"; } else if (sortCol == 1 && sortDir == "asc") { columnNameAsc = "Isbn"; } else if (sortCol == 1 && sortDir == "dsc") { columnNameDsc = "Isbn"; } else if (sortCol == 2 && sortDir == "asc") { columnNameAsc = "AuthorName"; } else if (sortCol == 2 && sortDir == "dsc") { columnNameDsc = "AuthorName"; } else if (sortCol == 3 && sortDir == "asc") { columnNameAsc = "BookPublish"; } else if (sortCol == 3 && sortDir == "dsc") { columnNameDsc = "BookPublish"; } else if (sortCol == 4 && sortDir == "asc") { columnNameAsc = "PurchaseDate"; } else if (sortCol == 4 && sortDir == "dsc") { columnNameDsc = "PurchaseDate"; } else if (sortCol == 5 && sortDir == "asc") { columnNameAsc = "Price"; } else if (sortCol == 5 && sortDir == "dsc") { columnNameDsc = "Price"; } else if (sortCol == 6 && sortDir == "asc") { columnNameAsc = "BookEdition"; } else if (sortCol == 6 && sortDir == "dsc") { columnNameDsc = "BookEdition"; } else if (sortCol == 7 && sortDir == "asc") { columnNameAsc = "BookQty"; } else if (sortCol == 7 && sortDir == "dsc") { columnNameDsc = "BookQty"; } if (sortDir == "asc" && string.IsNullOrEmpty(search) == false) { books = _LMContext.Books.OrderBy(x => columnNameAsc).Where(x => x.BookName.ToString().ToLower().Contains(search.ToLower()) || x.Isbn.ToString().ToLower().Contains(search.ToLower()) || x.AuthorName.ToString().ToLower().Contains(search.ToLower()) || x.BookPublish.ToString().ToLower().Contains(search.ToLower()) || x.PurchaseDate.ToString().ToLower().Contains(search.ToLower()) || x.Price.ToString().ToLower().Contains(search.ToLower()) || x.BookEdition.ToString().ToLower().Contains(search.ToLower()) || x.BookQty.ToString().ToLower().Contains(search.ToLower())).Include(y => y.BookPictures.Select(x => x.Pictures)).Include(w => w.Categories).ToList(); } else if (sortDir == "dsc" && string.IsNullOrEmpty(search) == false) { books = _LMContext.Books.OrderBy(x => columnNameDsc).Where(x => x.BookName.ToString().ToLower().Contains(search.ToLower()) || x.Isbn.ToString().ToLower().Contains(search.ToLower()) || x.AuthorName.ToString().ToLower().Contains(search.ToLower()) || x.BookPublish.ToString().ToLower().Contains(search.ToLower()) || x.PurchaseDate.ToString().ToLower().Contains(search.ToLower()) || x.Price.ToString().ToLower().Contains(search.ToLower()) || x.BookEdition.ToString().ToLower().Contains(search.ToLower()) || x.BookQty.ToString().ToLower().Contains(search.ToLower())).Include(y => y.BookPictures.Select(x => x.Pictures)).Include(w => w.Categories).ToList(); } else if (sortDir == "asc") { books = _LMContext.Books.OrderBy(x => columnNameAsc).Include(y => y.BookPictures.Select(x => x.Pictures)).Include(w => w.Categories).ToList(); } else { books = _LMContext.Books.OrderBy(x => columnNameDsc).Include(y => y.BookPictures.Select(x => x.Pictures)).Include(w => w.Categories).ToList(); } return(books); } }
public IssueRep(LMContext _db) { db = _db; }
public PictureServices() { _LMContext = new LMContext(); }
public MenuServices() { _LMContext = new LMContext(); }
public BookRep(LMContext _db) { db = _db; }