Exemplo n.º 1
0
        /***
         * 删除Event接口
         */
        public static async Task <bool> deleteEvent(String token, String id)
        {
            String jsonStr = JsonConvert.SerializeObject(new { token, id });
            var    res     = await BasicService.postRequestJSON("deleteEvent", jsonStr);

            return(res != null);
        }
Exemplo n.º 2
0
        /***
         * 创建事件接口, 可同时创建Place
         */
        public static async Task <bool> addEvent_NewPlace(String token, String name, String detail, String startTime, String endTime, String placeName, String address, String placeDetail, String price, String maxNum, StorageFile file = null)
        {
            var content = new MultipartFormDataContent();

            content.Add(new StringContent(token), "token");
            content.Add(new StringContent(name), "name");
            content.Add(new StringContent(detail), "detail");
            content.Add(new StringContent(startTime), "startTime");
            content.Add(new StringContent(endTime), "endTime");
            content.Add(new StringContent(placeName), "placeName");
            content.Add(new StringContent(placeDetail), "placeDetail");
            content.Add(new StringContent(address), "address");
            content.Add(new StringContent(maxNum), "maxNum");
            content.Add(new StringContent(price.ToString()), "price");

            if (file != null)
            {
                var streamData = await file.OpenStreamForReadAsync();

                var streamContent = new StreamContent(streamData);
                content.Add(streamContent, "image", file.Name);
            }

            var res = await BasicService.postRequestMultipartData("addEvent", content);

            return(res != null);
        }
Exemplo n.º 3
0
        /***
         * 获取所有当前可用地点
         */
        public static async Task <Places> getAllPlaces()
        {
            var    json      = JsonSerializer.Create();
            String placesStr = await BasicService.getRequest("getAllValidPlaces");

            return(json.Deserialize <Places>(new JsonTextReader(new StringReader(placesStr))));
        }
Exemplo n.º 4
0
        /***
         * 创建地点接口
         */
        public static async Task <string> addPlace(String token, String name, String address, String detail, Double price, StorageFile file = null)
        {
            var content = new MultipartFormDataContent();

            content.Add(new StringContent(token), "token");
            content.Add(new StringContent(name), "name");
            content.Add(new StringContent(address), "address");
            content.Add(new StringContent(detail), "detail");
            content.Add(new StringContent(price.ToString()), "price");

            if (file != null)
            {
                var streamData = await file.OpenStreamForReadAsync();

                var streamContent = new StreamContent(streamData);
                content.Add(streamContent, "image", file.Name);
            }
            var res = await BasicService.postRequestMultipartData("addPlace", content);

            if (res != null)
            {
                JObject id = (JObject)JsonConvert.DeserializeObject(res);
                return((string)id["place"]["name"]);
            }

            return("");
        }
Exemplo n.º 5
0
        /***
         * 登陆接口
         */
        public static async Task <JObject> Login(String account, String password)
        {
            string jsonStr      = JsonConvert.SerializeObject(new { account, password });
            string responseText = await BasicService.postRequestJSON("login", jsonStr);

            return((responseText == null) ? null : (JObject)JsonConvert.DeserializeObject(responseText));
        }
Exemplo n.º 6
0
        /***
         * 获取Place详情
         */
        public static async Task <PlaceDetailClass> getPlaceDetail(String token, String id)
        {
            string jsonStr   = JsonConvert.SerializeObject(new { token, id });
            var    json      = JsonSerializer.Create();
            String eventsStr = await BasicService.postRequestJSON("getDetailPlace", jsonStr);

            return((eventsStr == null) ? null : json.Deserialize <PlaceDetailClass>(new JsonTextReader(new StringReader(eventsStr))));
        }
Exemplo n.º 7
0
        /***
         * 获取所有用户拥有的地点
         */
        public static async Task <Places> getAllOwnedPlace(String token)
        {
            string jsonStr   = JsonConvert.SerializeObject(new { token });
            var    json      = JsonSerializer.Create();
            String placesStr = await BasicService.postRequestJSON("getAllOwnedPlaces", jsonStr);

            return(json.Deserialize <Places>(new JsonTextReader(new StringReader(placesStr))));
        }
Exemplo n.º 8
0
        /***
         * 根据Id获取单个PlaceItem
         */
        public static async Task <PlaceItem> getSingleEvent(String id)
        {
            String jsonStr  = JsonConvert.SerializeObject(new { id });
            String placeStr = await BasicService.postRequestJSON("getSinglePlace", jsonStr);

            var json = JsonSerializer.Create();

            return((placeStr == null) ? null : json.Deserialize <PlaceItem>(new JsonTextReader(new StringReader(placeStr))));
        }
Exemplo n.º 9
0
        /***
         * 根据Id获取单个EventItem
         */
        public static async Task <EventItem> getSingleEvent(String id)
        {
            String jsonStr  = JsonConvert.SerializeObject(new { id });
            String eventStr = await BasicService.postRequestJSON("getSingleEvent", jsonStr);

            var json = JsonSerializer.Create();

            if (eventStr == null)
            {
                return(null);
            }
            var eventItem = json.Deserialize <EventItem>(new JsonTextReader(new StringReader(eventStr)));

            eventItem.startTime = eventItem.startTime.ToLocalTime();
            eventItem.endTime   = eventItem.endTime.ToLocalTime();
            return(eventItem);
        }
Exemplo n.º 10
0
        /***
         * 获取Event详情
         */
        public static async Task <EventDetail> getEventDetail(String token, String id)
        {
            string jsonStr   = JsonConvert.SerializeObject(new { token, id });
            var    json      = JsonSerializer.Create();
            String eventsStr = await BasicService.postRequestJSON("getDetailEvent", jsonStr);

            if (eventsStr == null)
            {
                return(null);
            }
            EventDetail eventDetail = json.Deserialize <EventDetail>(new JsonTextReader(new StringReader(eventsStr)));

            eventDetail.detail.startTime = eventDetail.detail.startTime.ToLocalTime();
            eventDetail.detail.endTime   = eventDetail.detail.endTime.ToLocalTime();

            return(eventDetail);
        }
Exemplo n.º 11
0
        /***
         * 获取所有Event
         */
        public static async Task <Events> getAllEvents()
        {
            var    json      = JsonSerializer.Create();
            String eventsStr = await BasicService.getRequest("getAllEvents");

            if (eventsStr == null)
            {
                return(null);
            }
            Events events = json.Deserialize <Events>(new JsonTextReader(new StringReader(eventsStr)));

            foreach (var eventItem in events.events)
            {
                eventItem.startTime = eventItem.startTime.ToLocalTime();
                eventItem.endTime   = eventItem.endTime.ToLocalTime();
            }

            return(events);
        }
Exemplo n.º 12
0
        /***
         * 获取所有自己创建的Event
         */
        public static async Task <Events> getAllOwnedEvents(String token)
        {
            string jsonStr   = JsonConvert.SerializeObject(new { token });
            var    json      = JsonSerializer.Create();
            String eventsStr = await BasicService.postRequestJSON("getAllOwnedEvents", jsonStr);

            if (eventsStr == null)
            {
                return(null);
            }
            Events events = json.Deserialize <Events>(new JsonTextReader(new StringReader(eventsStr)));

            foreach (var eventItem in events.events)
            {
                eventItem.startTime = eventItem.startTime.ToLocalTime();
                eventItem.endTime   = eventItem.endTime.ToLocalTime();
            }

            return(events);
        }
Exemplo n.º 13
0
        /***
         * 注册
         */
        public static async Task <JObject> Register(String username, String email, String password, String phone, StorageFile file = null)
        {
            var content = new MultipartFormDataContent();

            content.Add(new StringContent(username), "username");
            content.Add(new StringContent(email), "email");
            content.Add(new StringContent(password), "password");
            content.Add(new StringContent(phone), "phone");

            if (file != null)
            {
                var streamData = await file.OpenStreamForReadAsync();

                var streamContent = new StreamContent(streamData);
                content.Add(streamContent, "image", file.Name);
            }
            var res = await BasicService.postRequestMultipartData("register", content);

            return((res == null) ? null : (JObject)JsonConvert.DeserializeObject(res));
        }
Exemplo n.º 14
0
        /***
         * 更新地点信息
         */
        public static async Task <bool> updatePlace(String token, String id, String name, String address, String detail, Double price, StorageFile file = null)
        {
            var content = new MultipartFormDataContent();

            content.Add(new StringContent(token), "token");
            content.Add(new StringContent(id), "id");
            content.Add(new StringContent(name), "name");
            content.Add(new StringContent(address), "address");
            content.Add(new StringContent(detail), "detail");
            content.Add(new StringContent(price.ToString()), "price");

            if (file != null)
            {
                var streamData = await file.OpenStreamForReadAsync();

                var streamContent = new StreamContent(streamData);
                content.Add(streamContent, "image", file.Name);
            }
            var res = await BasicService.postRequestMultipartData("updatePlace", content);

            return(res != null);
        }
Exemplo n.º 15
0
        /***
         * 更新Event接口
         */
        public static async Task <bool> updateEvent(String token, String id, String name, String detail, String startTime, String endTime, String PlaceId, String maxNum, StorageFile file = null)
        {
            var content = new MultipartFormDataContent();

            content.Add(new StringContent(id), "id");
            content.Add(new StringContent(token), "token");
            content.Add(new StringContent(name), "name");
            content.Add(new StringContent(detail), "detail");
            content.Add(new StringContent(startTime), "startTime");
            content.Add(new StringContent(endTime), "endTime");
            content.Add(new StringContent(PlaceId), "placeId");
            content.Add(new StringContent(maxNum), "maxNum");

            if (file != null)
            {
                var streamData = await file.OpenStreamForReadAsync();

                var streamContent = new StreamContent(streamData);
                content.Add(streamContent, "image", file.Name);
            }
            var res = await BasicService.postRequestMultipartData("updateEvent", content);

            return(res != null);
        }