Esempio n. 1
0
 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());
     }
 }
Esempio n. 3
0
        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));
     }
 }
Esempio n. 5
0
 public List <Room> GetAll()
 {
     using (var context = new ToplantiTakipContext())
     {
         return(context.Rooms.Include(c => c.Department).Where(c => c.RoomStatus == true).ToList());
     }
 }
Esempio n. 6
0
 public Department Get(int id)
 {
     using (var context = new ToplantiTakipContext())
     {
         var tag = context.Departments.Where(t => t.DepartmentId == id).SingleOrDefault();
         return(tag);
     }
 }
Esempio n. 7
0
 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);
     }
 }
Esempio n. 9
0
 public Room Add(Room entity)
 {
     using (var context = new ToplantiTakipContext())
     {
         context.Rooms.Add(entity);
         context.SaveChanges();
         return(entity);
     }
 }
Esempio n. 10
0
 public Department Add(Department entity)
 {
     using (var context = new ToplantiTakipContext())
     {
         context.Departments.Add(entity);
         context.SaveChanges();
         return(entity);
     }
 }
Esempio n. 11
0
        //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);
            }
        }
Esempio n. 12
0
 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();
         }
     }
 }
Esempio n. 13
0
 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();
         }
     }
 }
Esempio n. 14
0
        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);
            }
        }
Esempio n. 15
0
 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();
         }
     }
 }
Esempio n. 16
0
        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);
            }
        }
Esempio n. 17
0
        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);
            }
        }
Esempio n. 18
0
        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);
            }
        }
Esempio n. 19
0
        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);
            }
        }
Esempio n. 20
0
        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);
            }
        }