public string Post([FromBody] string value)
        {
            JObject          reponse;
            InformationModel model = JsonConvert.DeserializeObject <InformationModel>(value);

            if (CheckModel(model).Status == API.Status.ERROR.ToString())
            {
                reponse = JObject.FromObject(CheckModel(model));
                return(reponse.ToString());
            }
            DatabaseConnection databaseConnection = DatabaseConnection.GetInstance;

            PropertyInfo[] propertyInfos = model.GetType().GetProperties();
            string[]       columnname    = new string[propertyInfos.Length];
            int            index         = 0;

            foreach (PropertyInfo propertyInfo in propertyInfos)
            {
                columnname[index] = propertyInfo.Name;
                index++;
            }

            List <object> data = new List <object>();

            data.Add(model);
            JObject databaseReturn = databaseConnection.InsertData(TABLENAME, columnname, data);

            API.Status status  = (bool)databaseReturn["isError"] ? API.Status.ERROR : API.Status.DONE;
            string     message = (bool)databaseReturn["isError"] ? databaseReturn["message"].ToString() : "success";

            ResponseModel responsemodel = API.ParseReturn(status, message, (JObject)databaseReturn["data"]);

            reponse = JObject.FromObject(responsemodel);
            return(reponse.ToString());
        }
Esempio n. 2
0
        public static async Task <bool> UpdateStatus(Prospect p, API.Status status)
        {
            var client = new HttpClient();

            p.Status = (int)status;
            var data     = Newtonsoft.Json.JsonConvert.SerializeObject(p);
            var content  = new StringContent(data, Encoding.UTF8, "application/json");
            var url      = string.Format("{0}/{1}", API.ProspectsAPI, p.ProspectID);
            var response = await client.PutAsync(url, content);

            //PUT returns empty content, so we only care if the update was succesfull or not. In case of success server return 204
            return(response.IsSuccessStatusCode);
        }
        public string Delete(int id)
        {
            DatabaseConnection databaseConnection = DatabaseConnection.GetInstance;

            JObject databaseReturn = databaseConnection.DeleteData(TABLENAME, id);

            API.Status status  = (bool)databaseReturn["isError"] ? API.Status.ERROR : API.Status.DONE;
            string     message = (bool)databaseReturn["isError"] ? databaseReturn["message"].ToString() : "success";

            ResponseModel responsemodel = API.ParseReturn(status, message, (JObject)databaseReturn["data"]);
            JObject       reponse       = JObject.FromObject(responsemodel);

            return(reponse.ToString());
        }
        private string GetInformation(string mode = "ASC")
        {
            DatabaseConnection databaseConnection = DatabaseConnection.GetInstance;

            JObject order_by = new JObject();

            order_by.Add("column", "skillrate");
            order_by.Add("mode", mode);
            JObject databaseReturn = databaseConnection.SelectData(TABLENAME, 0, "id", order_by);

            API.Status status  = (bool)databaseReturn["isError"] ? API.Status.ERROR : API.Status.DONE;
            string     message = (bool)databaseReturn["isError"] ? databaseReturn["message"].ToString() : "success";

            ResponseModel responsemodel = API.ParseReturn(status, message, (JObject)databaseReturn["data"]);
            JObject       reponse       = JObject.FromObject(responsemodel);

            return(reponse.ToString());
        }