/// <summary>
 /// Get Comments on Event.
 /// </summary>
 /// <param name="eventID"></param>
 /// <returns></returns>
 public IList <CommentsDTO> GetComments(int eventID)
 {
     try
     {
         using (BookReadingEventContext db = new BookReadingEventContext())
         {
             return(mapCommentEntity2DTO.Map <IList <CommentsDTO> >(db.CommentsEntity.Where(p => p.EventID == eventID).ToList()));
         }
     }
     catch (Exception)
     {
         throw new DALException(Resource.DALErrorMessage);
     }
 }
Exemple #2
0
 /// <summary>
 /// Get User having a particular userID
 /// </summary>
 /// <param name="userID"></param>
 /// <returns></returns>
 public UserDTO GetUser(int userID)
 {
     try
     {
         using (BookReadingEventContext db = new BookReadingEventContext())
         {
             return(mapUserEntity2DTO.Map <UserDTO>(db.UserEntity.Find(userID)));
         }
     }
     catch (Exception)
     {
         throw new DALException(Resource.DALErrorMessage);
     }
 }
 /// <summary>
 /// View User's Events.
 /// </summary>
 /// <param name="userID"></param>
 /// <returns></returns>
 public IList <EventDTO> ViewMyEventsDAL(int userID)
 {
     try
     {
         using (BookReadingEventContext db = new BookReadingEventContext())
         {
             return(mapEventEntity2DTO.Map <IList <EventDTO> >(db.EventEntity.Where(e => e.UserID == userID).ToList()));
         }
     }
     catch (Exception)
     {
         throw new DALException(Resource.DALErrorMessage);
     }
 }
 /// <summary>
 /// get Details of Event having given eventID
 /// </summary>
 /// <param name="eventID"></param>
 /// <returns></returns>
 public EventDTO GetEventDAL(int eventID)
 {
     try
     {
         using (BookReadingEventContext db = new BookReadingEventContext())
         {
             return(mapEventEntity2DTO.Map <EventDTO>(db.EventEntity.Find(eventID)));
         }
     }
     catch (Exception)
     {
         throw new DALException(Resource.DALErrorMessage);
     }
 }
 /// <summary>
 /// View All Events for Admin.
 /// </summary>
 /// <returns></returns>
 public IList <EventDTO> AllEventsForAdminDAL()
 {
     try
     {
         using (BookReadingEventContext db = new BookReadingEventContext())
         {
             return(mapEventEntity2DTO.Map <IList <EventDTO> >(db.EventEntity.ToList()));
         }
     }
     catch (Exception)
     {
         throw new DALException(Resource.DALErrorMessage);
     }
 }
 /// <summary>
 /// view All public Events
 /// </summary>
 /// <returns></returns>
 public IList <EventDTO> ViewPublicEvents()
 {
     try
     {
         using (BookReadingEventContext db = new BookReadingEventContext())
         {
             return(mapEventEntity2DTO.Map <IList <EventDTO> >(db.EventEntity.Where(e => e.Type == Type.Public).ToList()));
         }
     }
     catch (Exception)
     {
         throw new DALException(Resource.DALErrorMessage);
     }
 }
 /// <summary>
 /// Add a comment to DataBase
 /// </summary>
 /// <param name="comment"></param>
 public CommentsDTO AddCommentDAL(CommentsDTO comment)
 {
     try
     {
         using (BookReadingEventContext db = new BookReadingEventContext())
         {
             CommentsEntity commentsEntity = mapCommentDTO2Entity.Map <CommentsEntity>(comment);
             db.CommentsEntity.Add(commentsEntity);
             db.SaveChanges();
             return(comment);
         }
     }
     catch (Exception)
     {
         throw new DALException(Resource.DALErrorMessage);
     }
 }
 /// <summary>
 /// Delete Event.
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public bool DeleteEventDAL(int id)
 {
     try
     {
         using (BookReadingEventContext db = new BookReadingEventContext())
         {
             EventEntity eventEntity = db.EventEntity.Find(id);
             db.EventEntity.Remove(eventEntity);
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception)
     {
         throw new DALException(Resource.DALErrorMessage);
     }
 }
Exemple #9
0
 /// <summary>
 /// Edit Details of user.
 /// </summary>
 /// <param name="userDTO"></param>
 /// <returns></returns>
 public UserDTO EditUser(UserDTO userDTO)
 {
     try
     {
         using (BookReadingEventContext db = new BookReadingEventContext())
         {
             UserEntity newUserEntity = mapUserDTO2Entity.Map <UserEntity>(userDTO);
             UserEntity oldUserEntity = db.UserEntity.Find(newUserEntity.UserID);
             db.Entry(oldUserEntity).CurrentValues.SetValues(newUserEntity);
             db.SaveChanges();
             return(userDTO);
         }
     }
     catch (Exception)
     {
         throw new DALException(Resource.DALErrorMessage);
     }
 }
Exemple #10
0
 /// <summary>
 /// Edit Event
 /// </summary>
 /// <param name="eventDTO"></param>
 /// <returns></returns>
 public EventDTO EditEventDAL(EventDTO eventDTO)
 {
     try
     {
         using (BookReadingEventContext db = new BookReadingEventContext())
         {
             EventEntity newEventEntity = mapEventDTO2Entity.Map <EventEntity>(eventDTO);
             EventEntity oldEventEntity = db.EventEntity.Find(newEventEntity.EventID);
             db.Entry(oldEventEntity).CurrentValues.SetValues(newEventEntity);
             db.SaveChanges();
             return(eventDTO);
         }
     }
     catch (Exception)
     {
         throw new DALException(Resource.DALErrorMessage);
     }
 }
Exemple #11
0
        /// <summary>
        /// Get Details of User
        /// </summary>
        /// <param name="userDTO"></param>
        /// <returns></returns>
        public UserDTO GetUserEntity(UserDTO userDTO)
        {
            try
            {
                using (BookReadingEventContext db = new BookReadingEventContext())
                {
                    UserEntity userEntity = mapUserDTO2Entity.Map <UserEntity>(userDTO);

                    var user = (from u in db.UserEntity
                                where (u.EmailID == userEntity.EmailID)
                                select u).FirstOrDefault();

                    return(mapUserEntity2DTO.Map <UserDTO>(user));
                }
            }
            catch (Exception)
            {
                throw new DALException(Resource.DALErrorMessage);
            }
        }
Exemple #12
0
        /// <summary>
        /// Create new User
        /// </summary>
        /// <param name="userDTO"></param>
        public UserDTO CreateUser(UserDTO userDTO)
        {
            try
            {
                using (BookReadingEventContext db = new BookReadingEventContext())
                {
                    UserEntity userEntity = mapUserDTO2Entity.Map <UserEntity>(userDTO);
                    db.UserEntity.Add(userEntity);
                    db.SaveChanges();
                    UserEntity user = (from u in db.UserEntity
                                       where (u.EmailID == userEntity.EmailID && u.Password == userEntity.Password)
                                       select u).FirstOrDefault();

                    return(mapUserEntity2DTO.Map <UserDTO>(user));
                }
            }
            catch (Exception)
            {
                throw new DALException(Resource.DALErrorMessage);
            }
        }
Exemple #13
0
        /// <summary>
        /// View All Events.
        /// </summary>
        /// <returns></returns>
        public IList <EventDTO> ViewAllEvents(int userID)
        {
            try
            {
                using (BookReadingEventContext db = new BookReadingEventContext())
                {
                    IList <EventEntity> userEvents   = db.EventEntity.Where(e => e.UserID == userID).ToList();
                    IList <EventEntity> publicEvents = db.EventEntity.Where(e => e.Type == Type.Public && e.UserID != userID).ToList();

                    foreach (var item in publicEvents)
                    {
                        userEvents.Add(item);
                    }
                    return(mapEventEntity2DTO.Map <IList <EventDTO> >(userEvents));
                }
            }
            catch (Exception)
            {
                throw new DALException(Resource.DALErrorMessage);
            }
        }
Exemple #14
0
        /// <summary>
        /// Add an Event to DataBase.
        /// </summary>
        /// <param name="eventDTO"></param>
        /// <returns></returns>
        public EventDTO AddEvent(EventDTO eventDTO)
        {
            try
            {
                using (BookReadingEventContext db = new BookReadingEventContext())
                {
                    EventEntity eventEntity = mapEventDTO2Entity.Map <EventEntity>(eventDTO);
                    db.EventEntity.Add(eventEntity);
                    db.SaveChanges();

                    EventEntity eventFetch = db.EventEntity.Where(s => (s.Title == eventEntity.Title && s.Starttime == eventEntity.Starttime && s.Location == eventEntity.Location)).FirstOrDefault();

                    //AddInvitesDAL(eventFetch.EventID, eventEntity.EventInvites);
                    eventDTO = mapEventEntity2DTO.Map <EventDTO>(eventFetch);

                    return(eventDTO);
                }
            }
            catch (Exception)
            {
                throw new DALException(Resource.DALErrorMessage);
            }
        }
Exemple #15
0
 /// <summary>
 /// populate Event recipients List.
 /// </summary>
 /// <param name="eventID"></param>
 /// <param name="eventInviteList"></param>
 public IList <string> AddInvitesDAL(IList <string> invites, int eventID)
 {
     try
     {
         using (BookReadingEventContext db = new BookReadingEventContext())
         {
             foreach (var item in invites)
             {
                 EventInvitesEntity eventInvitesEntity = new EventInvitesEntity
                 {
                     EventID = eventID,
                     EmailID = item
                 };
                 db.EventInvitesEntity.Add(eventInvitesEntity);
             }
             db.SaveChanges();
         }
         return(invites);
     }
     catch (Exception)
     {
         throw new DALException(Resource.DALErrorMessage);
     }
 }
Exemple #16
0
        /// <summary>
        /// View List of people Invited to Event.
        /// </summary>
        /// <param name="userID"></param>
        /// <returns></returns>
        public IList <EventDTO> ViewEventsInvitedToDAL(int userID)
        {
            try
            {
                using (BookReadingEventContext db = new BookReadingEventContext())
                {
                    UserEntity userEntity = db.UserEntity.Where(a => a.UserID == userID).FirstOrDefault();

                    IList <EventInvitesEntity> invites = db.EventInvitesEntity.Where(e => e.EmailID == userEntity.EmailID).ToList();

                    IList <EventDTO> eventsInvited = new List <EventDTO>();

                    foreach (var item in invites)
                    {
                        eventsInvited.Add(GetEventDAL(item.EventID));
                    }
                    return(eventsInvited);
                }
            }
            catch (Exception)
            {
                throw new DALException(Resource.DALErrorMessage);
            }
        }