Add Location C# Sample Code

Example: 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EasyHttp.Http;
using System.Dynamic;
 
namespace RestWebSvcCsharpConsoleTest
{
    class Program
    {
        static void Main(string[] args)
        {
            AddLocation();
        }
 
        static void AddLocation()
        {
            string url = "http://ws.bullseyelocations.com/RestLocation.svc/AddLocation";
            string ClientId = "";
            string ClientApiKey = ""; //admin API key
 
            //create a dynamic location object:
            dynamic newLoc = new ExpandoObject();
            newLoc.Name = "Sample Location";
 
            newLoc.Active = true;
            newLoc.CountryId = 1;        // US
            newLoc.Id = null;            // required
            newLoc.InternetLocation = false;
            newLoc.LocationTypeId = null;    // leave null to set to default (Standard). 
 
            newLoc.Address1 = "Address1";
            newLoc.City = "Somerset";
            newLoc.StateAbbr = "NJ";
            newLoc.PostCode = "08873";
            newLoc.PhoneNumber = "111-222-3333";
            newLoc.ThirdPartyId = "123";
            newLoc.FacebookPageId = "FacebookPageID"; //optional
 
            newLoc.Services = new List<dynamic>();
            newLoc.Services.Add(new ExpandoObject());
            newLoc.Services[0].ServiceID = 2;        // store locator
 
            // For each of the Open and Closed fields, you need to pass in a valid DateTime value, but the date portion is ignored.  
            // If a location is closed on a given day, pass in NULL for both Open and Close values.
            DateTime MondayOpen = new DateTime(2015, 1, 1, 9, 0, 0, DateTimeKind.Utc);
            DateTime MondayClose = new DateTime(2015, 1, 1, 17, 0, 0, DateTimeKind.Utc);
 
             dynamic locBH = new ExpandoObject();
            //A list of time zones can be obtained via the GetTimeZones() method.
            locBH.TimeZoneID = 17;//Eastern Time (US & Canada)
            locBH.MondayOpen = "/Date(" + ToUnixTime(MondayOpen) + ")/";
            locBH.MondayClose = "/Date(" + ToUnixTime(MondayClose) + ")/"; ;
            locBH.TuesdayOpen = null;
            locBH.TuesdayClose = null;
            locBH.WednesdayOpen = null;
            locBH.WednesdayClose = null;
            locBH.ThursdayOpen = null;
            locBH.ThursdayClose = null;
            locBH.FridayOpen = null;
            locBH.FridayClose = null;
            locBH.SaturdayOpen = null;
            locBH.SaturdayClose = null;
            locBH.SundayOpen = null;
            locBH.SundayClose = null;
 
            newLoc.BusinessHours = locBH;
 
            //Adding custom attributes
            //dynamic attr = new List<dynamic>();
            //int index = 0;
 
            //attr.Add(new ExpandoObject());
            //attr[index].AttributeId = 0; //id of the attribute
            ////attr[index].OptionID = optionID; // if multi-option attribute
            //attr[index].TextValue = "This is a test"; // if text attribute
 
            //if adding multiple attributes
            //if (((List<dynamic>)attr).Count > 0)
            //  index++;
 
            //attr.Add(new ExpandoObject());
            //attr[index].OptionID = optionID; // if multi-option attribute
            //attr[index].TextValue = "This is a test"; // if text attribute
 
            //if (((List<dynamic>)attr).Count > 0)
            //    newLoc.Attributes = attr;
 
            // our method parameters:
            dynamic vCreateLocParms = new ExpandoObject();
            vCreateLocParms.ClientId = ClientId;
            vCreateLocParms.ApiKey = ClientApiKey; 
            vCreateLocParms.myLoc = newLoc;
 
            var http = new HttpClient
            {
                Request = { Accept = HttpContentTypes.ApplicationJson }
            };
 
            http.Post(url, vCreateLocParms, HttpContentTypes.ApplicationJson);
 
            var response = http.Response;
 
            var statcode = response.StatusCode;
            string statdesc = response.StatusDescription;
 
            if (statcode != System.Net.HttpStatusCode.OK)
            {
                Console.WriteLine(string.Format("Error: response code = {0}", statdesc));
                return;
            }
 
            // get the raw JSON:
            string rawresp = response.RawText;
 
            if (string.IsNullOrEmpty(rawresp))
            {
                Console.WriteLine("Error: no response text received from server.");
                return;
            }
 
            dynamic myResult = response.RawText;
            Console.WriteLine(myResult);
 
            Console.WriteLine("Press any key...");
            Console.ReadKey();
        }
 
        private static long ToUnixTime(DateTime date)
        {
            var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
            return Convert.ToInt64(date.Subtract(epoch).TotalMilliseconds);
        }
    }
}