Exemple #1
0
        public ResponseObject <QuickEvent> GetEvent(string id)
        {
            dynamic response = new ResponseObject <QuickEvent>();

            try
            {
                int eventID = Int32.Parse(id);
                eventfinderEntitiesModel model = new eventfinderEntitiesModel();
                Event eventEntity = model.Events.First(e => e.ID == eventID);

                QuickEvent quickEvent = new QuickEvent()
                {
                    ID          = eventEntity.ID,
                    UserID      = eventEntity.UserID,
                    Name        = eventEntity.Name,
                    Description = eventEntity.Description,
                    StartTime   = eventEntity.StartTime.ToString(),
                    EndTime     = eventEntity.EndTime.ToString(),
                    Latitude    = eventEntity.Latitude,
                    Longtitude  = eventEntity.Longitude,
                    Type        = eventEntity.Type
                };

                response.data    = quickEvent;
                response.success = true;
            }
            catch (Exception)
            {
                response.success = false;
                response.message = string.Format("error on GetEvent eventID={0}", id);
            }
            return(response);
        }
Exemple #2
0
        public ResponseObject <List <QuickEvent> > GetEvents()
        {
            dynamic response = new ResponseObject <List <QuickEvent> >();

            try
            {
                List <QuickEvent>        events      = new List <QuickEvent>();
                eventfinderEntitiesModel model       = new eventfinderEntitiesModel();
                ICollection <Event>      eventEntity = model.Events.ToList();
                foreach (var e in eventEntity)
                {
                    events.Add(new QuickEvent()
                    {
                        ID          = e.ID,
                        UserID      = e.UserID,
                        Name        = e.Name,
                        Description = e.Description,
                        StartTime   = e.StartTime.ToString(),
                        EndTime     = e.EndTime.ToString(),
                        Latitude    = e.Latitude,
                        Longtitude  = e.Longitude,
                        Type        = e.Type
                    });
                }
                response.data    = events;
                response.success = true;
            }
            catch (Exception)
            {
                response.success = false;
                response.message = "error on GetEvents";
            }
            return(response);
        }
Exemple #3
0
        public ResponseObject <List <QuickUser> > GetEventAttendings(string eventID)
        {
            dynamic response = new ResponseObject <List <QuickUser> >();

            try
            {
                List <QuickUser> attendings = new List <QuickUser>();
                int ID = Int32.Parse(eventID);
                eventfinderEntitiesModel model = new eventfinderEntitiesModel();
                Event eventEntity             = model.Events.First(e => e.ID == ID);
                ICollection <User> userEntity = eventEntity.Users.ToList();
                foreach (var u in userEntity)
                {
                    attendings.Add(new QuickUser()
                    {
                        ID          = u.ID,
                        FirstName   = u.FirstName,
                        LastName    = u.LastName,
                        PhoneNumber = u.PhoneNumber
                    });
                }
                response.data    = attendings;
                response.success = true;
            }
            catch (Exception)
            {
                response.success = false;
                response.message = "error on GetEventAttendings";
            }
            return(response);
        }
Exemple #4
0
        public ResponseObject <int> Register(RegisterUser user)
        {
            dynamic response = new ResponseObject <int>();

            try
            {
                eventfinderEntitiesModel ent = new eventfinderEntitiesModel();
                User userEntity = new User()
                {
                    Email       = user.Email,
                    Password    = user.Password,
                    FirstName   = user.FirstName,
                    LastName    = user.LastName,
                    PhoneNumber = user.PhoneNumber
                };
                ent.Users.Add(userEntity);
                ent.SaveChanges();
                SaveUserPhoneID(user.PhoneID, userEntity.ID.ToString());
                response.data    = userEntity.ID;
                response.success = true;
            }
            catch (Exception)
            {
                response.success = false;
                response.message = string.Format("error on Register email={0}", user.Email);
            }

            return(response);
        }
Exemple #5
0
        public ResponseObject <bool> JoinEvent(string eventID, string userID)
        {
            dynamic response = new ResponseObject <bool>();

            try
            {
                int user    = Int32.Parse(userID);
                int eventId = Int32.Parse(eventID);
                eventfinderEntitiesModel model = new eventfinderEntitiesModel();
                Event eventEntity = model.Events.First(e => e.ID == eventId);
                User  userEntity  = model.Users.First(u => u.ID == user);
                eventEntity.Users.Add(userEntity);
                model.SaveChanges();
                var storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("DataConnectionString"));
                var queueEvent     = storageAccount.CreateCloudQueueClient();
                var queue          = queueEvent.GetQueueReference("joineventqueue");
                queue.CreateIfNotExists(null);
                string message = "EventID " + eventEntity.ID + " UserID " + userID;
                var    msg     = new CloudQueueMessage(message);
                queue.AddMessage(msg);
                response.success = true;
                response.data    = true;
            }
            catch (Exception)
            {
                response.success = false;
                response.message = string.Format("error on JoinEvent eventID={0} userID={1}", eventID, userID);
            }
            return(response);
        }
Exemple #6
0
        public ResponseObject <QuickEvent> AddEvent(QuickEvent newEvent)
        {
            dynamic response = new ResponseObject <QuickEvent>();

            try
            {
                DateTime start               = Convert.ToDateTime(newEvent.StartTime);
                DateTime end                 = Convert.ToDateTime(newEvent.EndTime);
                double   latitudePoint       = Convert.ToDouble(newEvent.Latitude);
                double   longitudePoint      = Convert.ToDouble(newEvent.Longtitude);
                eventfinderEntitiesModel ent = new eventfinderEntitiesModel();
                User  userEntity             = ent.Users.First(u => u.ID == newEvent.UserID);
                Event eventEntity            = new Event()
                {
                    Name        = newEvent.Name,
                    StartTime   = start,
                    EndTime     = end,
                    UserID      = newEvent.UserID,
                    Latitude    = latitudePoint,
                    Longitude   = longitudePoint,
                    Description = newEvent.Description,
                    User        = userEntity,
                    Type        = newEvent.Type
                };
                ent.Events.Add(eventEntity);
                ent.SaveChanges();
                int eventID = eventEntity.ID;
                newEvent.ID = eventID;
                var storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("DataConnectionString"));// retrieve a reference to the messages queue
                var queueEvent     = storageAccount.CreateCloudQueueClient();
                var queue          = queueEvent.GetQueueReference("neweventqueue");
                queue.CreateIfNotExists(null);
                var msg = new CloudQueueMessage(eventID.ToString());
                queue.AddMessage(msg);
                //SaveImageInBlob(newEvent.ID, new System.IO.MemoryStream());
                response.data    = newEvent;
                response.success = true;
            }
            catch (Exception)
            {
                response.success = false;
                response.message = string.Format("error on AddEvent event name={0}", newEvent.Name);
            }
            return(response);
        }
Exemple #7
0
        public ResponseObject <int> Login(LoginDetails loginDetails)
        {
            dynamic response = new ResponseObject <int>();

            try
            {
                eventfinderEntitiesModel model = new eventfinderEntitiesModel();
                User userEntity = model.Users.First(e => e.Email == loginDetails.Email && e.Password == loginDetails.Password);
                response.data    = userEntity.ID;
                response.success = true;
            }
            catch (Exception)
            {
                response.success = false;
                response.message = string.Format("error on Login email={0} password={1}", loginDetails.Email, loginDetails.Password);
            }
            return(response);
        }