コード例 #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);
        }
コード例 #2
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);
        }