Beispiel #1
0
        public static void MuaSetAvailability(string muaId, Availibility a, Action <ResponseDataJson> callback)
        {
            var jObj = new JObject();

            jObj["MuaId"] = muaId;
            jObj["Mode"]  = (int)a.Mode;
            if (a.DaysOfWeek != null)
            {
                var sb = new StringBuilder();
                foreach (var d in a.DaysOfWeek)
                {
                    sb.Append(d);
                    sb.Append(",");
                }
                sb.Length--;
                jObj["DaysOfWeek"] = sb.ToString();
            }
            var fromArray = new JArray();
            var toArray   = new JArray();

            foreach (var dt in a.DatesFrom)
            {
                fromArray.Add(dt.ToUniversalTime());
            }
            foreach (var dt in a.DatesTo)
            {
                toArray.Add(dt.ToUniversalTime());
            }
            jObj["DatesFrom"] = fromArray;
            jObj["DatesTo"]   = toArray;
            MakeRequestJson("mua/setavailability", jObj.ToString(), callback);
        }
Beispiel #2
0
        public static Availibility Parse(string str)
        {
            var avail = new Availibility();

            try
            {
                var aObj = JObject.Parse(str);
                avail.Mode      = (AvailibilityMode)(int)aObj["Mode"];
                avail.DatesFrom = new List <DateTime>();
                avail.DatesTo   = new List <DateTime>();
                foreach (DateTime d in (Newtonsoft.Json.Linq.JArray)aObj["DatesFrom"])
                {
                    avail.DatesFrom.Add(d);
                }
                foreach (DateTime d in (Newtonsoft.Json.Linq.JArray)aObj["DatesTo"])
                {
                    avail.DatesTo.Add(d);
                }
                if (avail.Mode == AvailibilityMode.DaysOfWeek)
                {
                    avail.DaysOfWeek = new List <int>();
                    var days = ((string)aObj["DaysOfWeek"]).Split(',');
                    foreach (var d in days)
                    {
                        avail.DaysOfWeek.Add(int.Parse(d));
                    }
                }
            }
            catch { }
            return(avail);
        }
Beispiel #3
0
        public static void MuaSearchFree(List <string> categories, Pages.LocationFilter lFilter, Availibility aFilter, Action <ResponseDataJson> callback)
        {
            var body        = new JObject();
            var categoryArr = new JArray();

            body["CategoryFilter"] = categoryArr;
            foreach (var c in categories)
            {
                categoryArr.Add(c);
            }
            if (lFilter != null)
            {
                var obj = new JObject();
                obj["Lat"]             = lFilter.Lat;
                obj["Lon"]             = lFilter.Lon;
                obj["Radius"]          = lFilter.Radius;
                body["LocationFilter"] = obj;
            }
            if (aFilter != null)
            {
                var obj = new JObject();
                obj["From"] = aFilter.DatesFrom[0].ToUniversalTime();
                obj["To"]   = aFilter.DatesTo[0].ToUniversalTime();
                body["AvailibilityFilter"] = obj;
            }
            MakeRequestJson("mua/searchfree", body.ToString(), callback);
        }