public Room Get(int id) { using (var context = new ToplantiTakipContext()) { return(context.Rooms.Include(c => c.Department).SingleOrDefault(c => c.RoomStatus == true && c.RoomId == id)); } }
public List <EventDocument> GetAll() { using (var context = new ToplantiTakipContext()) { return(context.EventDocuments.Include(c => c.Event).ToList()); } }
public Event Update(Event entity) { using (var context = new ToplantiTakipContext()) { var _event = context.Events.Include(x => x.EventDocument).FirstOrDefault(d => d.EventId == entity.EventId); _event.EventInfo = entity.EventInfo; _event.EventSubject = entity.EventSubject; _event.StartDate = entity.StartDate; _event.EndDate = entity.EndDate; _event.RoomId = entity.RoomId; _event.ReservationDate = entity.ReservationDate; _event.ApproveDate = entity.ApproveDate; _event.ApproveUserId = entity.ApproveUserId; _event.UserId = entity.UserId; _event.Status = entity.Status; _event.ThemeColor = entity.ThemeColor; if (entity.EventDocument != null && entity.EventDocument.Count > 0) { _event.EventDocument.AddRange(entity.EventDocument); } // context.Entry(entity.EventDocument).State = EntityState.Added; //context.Entry(entity).State = EntityState.Modified; context.SaveChanges(); return(_event); } }
public EventDocument Get(int id) { using (var context = new ToplantiTakipContext()) { return(context.EventDocuments.Include(c => c.Event).SingleOrDefault(c => c.EventDocumentId == id)); } }
public List <Room> GetAll() { using (var context = new ToplantiTakipContext()) { return(context.Rooms.Include(c => c.Department).Where(c => c.RoomStatus == true).ToList()); } }
public Department Get(int id) { using (var context = new ToplantiTakipContext()) { var tag = context.Departments.Where(t => t.DepartmentId == id).SingleOrDefault(); return(tag); } }
public List <Department> GetAll() { using (var context = new ToplantiTakipContext()) { var tag = context.Departments.ToList(); return(tag); } }
public EventDocument Add(EventDocument entity) { using (var context = new ToplantiTakipContext()) { context.EventDocuments.Add(entity); context.SaveChanges(); return(entity); } }
public Room Add(Room entity) { using (var context = new ToplantiTakipContext()) { context.Rooms.Add(entity); context.SaveChanges(); return(entity); } }
public Department Add(Department entity) { using (var context = new ToplantiTakipContext()) { context.Departments.Add(entity); context.SaveChanges(); return(entity); } }
//public List<Event> GetMostCommentedEvents() //{ // using (var _context = new ToplantiTakipContext()) // { // var Events = (from p in _context.Events.Include(c => c.Comments) // where p.EventStatus == true // orderby p.Comments.Count() descending // select p).Take(5).ToList(); // return Events; // } //} //public List<Event> GetMostViewedEvents() //{ // using (var _context = new ToplantiTakipContext()) // { // List<Event> Event = (from p in _context.Events.Include(p => p.Tags).Include(p => p.Author) // where p.EventStatus == true // orderby p.ViewCount descending // select p).ToList(); // return Event; // } //} public Event Get(int EventId) { using (var _context = new ToplantiTakipContext()) { Event Event = (from p in _context.Events.Include(p => p.Room).Include(p => p.EventDocument).Include(p => p.User) where p.EventId == EventId select p).Single(); return(Event); } }
public void Delete(EventDocument entity) { using (var context = new ToplantiTakipContext()) { var room = context.EventDocuments.Find(entity.EventDocumentId); if (room != null) { context.EventDocuments.Remove(room); context.SaveChanges(); } } }
public void Delete(Department entity) { using (var context = new ToplantiTakipContext()) { var tag = context.Departments.Find(entity.DepartmentId); if (tag != null) { context.Departments.Remove(tag); context.SaveChanges(); } } }
public List <Event> GetByRoomId(int?roomId) { using (var _context = new ToplantiTakipContext()) { var Event = (from p in _context.Events where p.RoomId == roomId orderby p.EventId descending select p).ToList(); return(Event); } }
public void Delete(Event entity) { using (var _context = new ToplantiTakipContext()) { var Event = _context.Events.Include(p => p.Room).First(x => x.EventId == entity.EventId); if (Event != null) { _context.Events.Remove(Event); _context.SaveChanges(); } } }
public List <Event> GetAllwithRooms() { using (var _context = new ToplantiTakipContext()) { List <Event> Event = (from p in _context.Events // where p.EventStatus == true orderby p.EventId descending select p).ToList(); return(Event); } }
public List <Event> GetAll() { using (var _context = new ToplantiTakipContext()) { List <Event> Event = (from p in _context.Events.Include(p => p.Room).Include(p => p.Room.Department) // where p.EventStatus == true orderby p.EventId descending select p).ToList(); return(Event); } }
public Department Update(Department entity) { using (var context = new ToplantiTakipContext()) { var tag = context.Departments.FirstOrDefault(d => d.DepartmentId == entity.DepartmentId); tag.DepartmentAddress = entity.DepartmentAddress; tag.DepartmentInfo = entity.DepartmentInfo; tag.DepartmentStatus = entity.DepartmentStatus; //context.Entry(entity).State = EntityState.Modified; context.SaveChanges(); return(tag); } }
public EventDocument Update(EventDocument entity) { using (var context = new ToplantiTakipContext()) { var room = context.EventDocuments.FirstOrDefault(d => d.EventDocumentId == entity.EventDocumentId); room.Document = entity.Document; room.DocumentName = entity.DocumentName; room.DocumentType = entity.DocumentType; room.EventId = entity.EventId; //context.Entry(entity).State = EntityState.Modified; context.SaveChanges(); return(room); } }
public Room Update(Room entity) { using (var context = new ToplantiTakipContext()) { var room = context.Rooms.FirstOrDefault(d => d.RoomId == entity.RoomId); room.RoomInfo = entity.RoomInfo; room.RoomName = entity.RoomName; room.RoomStatus = entity.RoomStatus; room.RoomAddress = entity.RoomAddress; room.RoomInfo = entity.RoomInfo; room.RoomCapacity = entity.RoomCapacity; room.DepartmentId = entity.DepartmentId; if (entity.RoomImage != null && room.RoomImage != entity.RoomImage) { room.RoomImage = entity.RoomImage; room.ImageType = entity.ImageType; } //context.Entry(entity).State = EntityState.Modified; context.SaveChanges(); return(room); } }