public new List <Device> GetDeviceListFromCompanyID(int companyID)
        {
            try
            {
                string url  = IoC.API_URL + "device/getDevicesByCompanyID";
                string json = companyID.ToString();

                HttpWebRequest       request = Connect_dl.BuildRequest(url, "POST", json);
                Tuple <bool, string> result  = ValidateResponse(request);

                if (result.Item1)
                {
                    List <Device> devices = Newtonsoft.Json.JsonConvert.DeserializeObject <List <Device> >(result.Item2);
                    return(devices);
                }
                else
                {
                    //return empty list
                    List <Device> devices = new List <Device>();
                    return(devices);
                }
            }
            catch
            {
                return(null);
            }
        }
        public new Device Update()
        {
            try
            {
                string url  = IoC.API_URL + "device/updateAndReturn";
                string json = Connect_dl.BuildJson(this, true);

                HttpWebRequest       request = Connect_dl.BuildRequest(url, "POST", json);
                Tuple <bool, string> result  = ValidateResponse(request);

                if (result.Item1)
                {
                    Device deviceUpdate = Newtonsoft.Json.JsonConvert.DeserializeObject <Device>(result.Item2);
                    return(deviceUpdate);
                }
                else
                {
                    return(null);
                }
            }
            catch
            {
                return(null);
            }
        }
        public new Device Fill()
        {
            try
            {
                string url  = IoC.API_URL + "device/fill";
                string json = this.DeviceID.ToString();

                HttpWebRequest       request = Connect_dl.BuildRequest(url, "POST", json);
                Tuple <bool, string> result  = ValidateResponse(request);

                if (result.Item1)
                {
                    Device deviceFill = Newtonsoft.Json.JsonConvert.DeserializeObject <Device>(result.Item2);
                    return(deviceFill);
                }
                else
                {
                    return(null);
                }
            }
            catch
            {
                return(null);
            }
        }
        public new ParkingLot Create()
        {
            string url  = IoC.API_URL + "parkingLot/create";
            string json = Connect_dl.BuildJson(this);

            HttpWebRequest request = Connect_dl.BuildRequest(url, "POST", json);

            return(ValidateResponse("Create", request) as ParkingLot);
        }
        public new bool?Delete()
        {
            string url  = IoC.API_URL + "parkingLot/delete";
            string json = this.LotID.ToString();

            HttpWebRequest request = Connect_dl.BuildRequest(url, "POST", json);

            return(ValidateResponse("Delete", request) as bool?);
        }
        public new List <Device> GetCamerasDeployed()
        {
            string url  = IoC.API_URL + "parkingLot/getCamerasDeployedAtParkingLot";
            string json = Connect_dl.BuildJson(this);

            HttpWebRequest request = Connect_dl.BuildRequest(url, "POST", json);

            return(ValidateResponse("GetCamerasDeployed", request) as List <Device>);
        }
        public new List <ParkingLot> GetParkingLotListFromCompanyID(int companyID)
        {
            string url  = IoC.API_URL + "parkingLot/getParkingLotsByCompanyId";
            string json = companyID.ToString();

            HttpWebRequest request = Connect_dl.BuildRequest(url, "POST", json);

            return(ValidateResponse("GetParkingLotListFromCompanyID", request) as List <ParkingLot>);
        }
        public new ParkingLot Fill()
        {
            ParkingLot parkingLot = new ParkingLot();

            parkingLot.LotID = this.LotID;

            string url  = IoC.API_URL + "parkingLot/fill";
            string json = this.LotID.ToString();

            HttpWebRequest request = Connect_dl.BuildRequest(url, "POST", json);

            return(ValidateResponse("Fill", request) as ParkingLot);
        }
        public new bool?SignUp()
        {
            string url  = IoC.API_URL + "company/signUp";
            string json = Connect_dl.BuildJson(this);

            HttpWebRequest request = Connect_dl.BuildRequest(url, "POST", json);

            if (request != null)
            {
                Dictionary <HttpStatusCode, string> response = Connect_dl.GetResponse(request);
                HttpStatusCode code         = response.FirstOrDefault().Key;
                string         httpResponse = response.FirstOrDefault().Value;

                if (code == HttpStatusCode.OK)
                {
                    //clear company in IoC, return true
                    Company company = new Company();
                    IoC.CurrentCompany = company;
                    return(true);
                }
                else
                {
                    if (httpResponse == "Company already exists with specified username.")
                    {
                        //clear company, return false for incorrect username/password
                        IoC.ClearSessionIoC();
                        return(false);
                    }
                    else
                    {
                        //clear company, return null for server error
                        IoC.ClearSessionIoC();
                        return(null);
                    }
                }
            }
            else
            {
                //clear company, return null for server error
                IoC.ClearSessionIoC();
                return(null);
            }
        }
        public new bool?Login()
        {
            string url  = IoC.API_URL + "company/login";
            string json = Connect_dl.BuildJson(this);

            HttpWebRequest request = Connect_dl.BuildRequest(url, "POST", json);

            if (request != null)
            {
                Dictionary <HttpStatusCode, string> response = Connect_dl.GetResponse(request);
                HttpStatusCode code         = response.FirstOrDefault().Key;
                string         httpResponse = response.FirstOrDefault().Value;

                if (code == HttpStatusCode.OK)
                {
                    //save company in IoC, return true
                    Company currentCompany = Newtonsoft.Json.JsonConvert.DeserializeObject <Company>(httpResponse);
                    IoC.CurrentCompany = currentCompany;
                    return(true);
                }
                else
                {
                    if (httpResponse == "Incorrect Username or Password")
                    {
                        //clear company, return false for incorrect username/password
                        IoC.ClearSessionIoC();
                        return(false);
                    }
                    else
                    {
                        //clear company, return null for server error
                        IoC.ClearSessionIoC();
                        return(null);
                    }
                }
            }
            else
            {
                //clear company, return null for server error
                IoC.ClearSessionIoC();
                return(null);
            }
        }
        public new bool SaveSpots(List <Spot> spotList)
        {
            try
            {
                string url  = IoC.API_URL + "device/saveSpots";
                string json = JsonConvert.SerializeObject(spotList);

                HttpWebRequest       request = Connect_dl.BuildRequest(url, "POST", json);
                Tuple <bool, string> result  = ValidateResponse(request);

                if (result.Item1)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch
            {
                return(false);
            }
        }
        public new bool ClearImage()
        {
            try
            {
                string url  = IoC.API_URL + "device/clearImageFromDatabase";
                string json = this.DeviceID.ToString();

                HttpWebRequest       request = Connect_dl.BuildRequest(url, "POST", json);
                Tuple <bool, string> result  = ValidateResponse(request);

                if (result.Item1)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch
            {
                return(false);
            }
        }
        public new string GetEncodedImageString()
        {
            try
            {
                string url  = IoC.API_URL + "device/retrieveImageString";
                string json = this.DeviceID.ToString();

                HttpWebRequest       request = Connect_dl.BuildRequest(url, "POST", json);
                Tuple <bool, string> result  = ValidateResponse(request);

                if (result.Item1)
                {
                    return(result.Item2);
                }
                else
                {
                    return(null);
                }
            }
            catch
            {
                return(null);
            }
        }