public ActionResult GetProjectByName(string projectName)
        {
            var watch = System.Diagnostics.Stopwatch.StartNew();

            GlobalVars.ResultProjects resultProjects = new GlobalVars.ResultProjects();
            try
            {
                logger.Info("GetProjectsByName API Request. Project Name: " + projectName);
                if (string.IsNullOrEmpty(projectName))
                {
                    Response.StatusCode       = (int)HttpStatusCode.BadRequest;
                    resultProjects.ReturnCode = -1;
                    resultProjects.Message    = "Missing argument Project Name";
                    logger.Warn("GetProjectsByName API Request ends with an Error.");
                    logger.Warn(resultProjects.Message);
                }
                else
                {
                    resultProjects = SQLFunctionsProjects.GetProjectByName(projectName);
                    switch (resultProjects.ReturnCode)
                    {
                    case 0:
                        logger.Info("GetProjectsByName API Request was executed Successfully.");
                        Response.StatusCode = (int)HttpStatusCode.OK;
                        break;

                    case -2:
                        Response.StatusCode = (int)HttpStatusCode.InternalServerError;
                        logger.Fatal("GetProjectsByName API Request ends with a Fatal Error.");
                        logger.Debug("Returned value:" + JsonConvert.SerializeObject(resultProjects, Formatting.Indented));
                        Response.StatusCode = (int)HttpStatusCode.InternalServerError;
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                logger.Fatal("GetProjectsByName API Request ends with a Fatal Error.");
                resultProjects.ReturnCode = -2;
                resultProjects.Message    = e.Message;
                var baseException = e.GetBaseException();
                resultProjects.Exception = baseException.ToString();
                logger.Fatal("Returned value:" + JsonConvert.SerializeObject(resultProjects, Formatting.Indented));
                Response.StatusCode = (int)HttpStatusCode.InternalServerError;
            }
            Response.ContentType = "application/json";
            watch.Stop();
            var elapsedMs = watch.ElapsedMilliseconds;

            elapsedMs = elapsedMs / 1000;
            resultProjects.ElapsedTime = elapsedMs.ToString();
            logger.Debug("Returned value:" + JsonConvert.SerializeObject(resultProjects, Formatting.Indented));
            //var messaje = JsonConvert.SerializeObject(resultCustomers, Formatting.Indented);
            resultProjects.HttpStatusCode = Response.StatusCode.ToString();
            var messaje = JsonConvert.SerializeObject(resultProjects, Formatting.Indented);

            logger.Info("Leaving GetProjectsByName API.");
            //return Json(messaje);
            return(Content(messaje));
        }
        public ActionResult UpdateProject([FromBody] string projectJS)
        {
            var watch = System.Diagnostics.Stopwatch.StartNew();

            GlobalVars.ResultGeneric result = new GlobalVars.ResultGeneric()
            {
                Message    = "",
                ReturnCode = 0,
                //ReturnValue = ""
            };
            try
            {
                if (projectJS == null)
                {
                    Response.StatusCode = (int)HttpStatusCode.BadRequest;
                    result.ReturnCode   = -1;
                    result.Message      = "Missing argument projectJS";
                    logger.Warn("UpdateProject API Request ends with an Error.");
                    logger.Warn(result.Message);
                }
                else
                {
                    GlobalVars.Project project = JsonConvert.DeserializeObject <GlobalVars.Project>(projectJS);
                    logger.Info("UpdateProject API Request.");
                    if (!string.IsNullOrEmpty(project.ProjectName))
                    {
                        logger.Debug("Parameter:" + JsonConvert.SerializeObject(project, Formatting.Indented));

                        result = SQLFunctionsProjects.UpdateProject(project);
                        switch (result.ReturnCode)
                        {
                        case 0:
                            logger.Info("UpdateProject API Request was executed Successfully.");
                            Response.StatusCode = (int)HttpStatusCode.OK;
                            break;

                        case -1:
                            logger.Info("UpdateProject API Request ends with a warning.");
                            Response.StatusCode = (int)HttpStatusCode.OK;
                            break;

                        case -2:
                            Response.StatusCode = (int)HttpStatusCode.InternalServerError;
                            logger.Fatal("UpdateProject API Request ends with a Fatal Error.");
                            logger.Debug("Returned value:" + JsonConvert.SerializeObject(result, Formatting.Indented));
                            Response.StatusCode = (int)HttpStatusCode.InternalServerError;
                            break;
                        }
                    }
                    else
                    {
                        Response.StatusCode = (int)HttpStatusCode.BadRequest;
                        result.ReturnCode   = -1;
                        result.Message      = "UpdateProject value is not valid.";
                        logger.Warn("UpdateProject API Request ends with an Error.");
                        logger.Warn(result.Message);
                    }
                }
            }
            catch (Exception e)
            {
                logger.Fatal("UpdateProject API Request ends with a Fatal Error.");
                result.ReturnCode = -2;
                result.Message    = e.Message;
                var baseException = e.GetBaseException();
                result.Exception = baseException.ToString();
                logger.Fatal("Returned value:" + JsonConvert.SerializeObject(result, Formatting.Indented));
                Response.StatusCode = (int)HttpStatusCode.InternalServerError;
            }
            Response.ContentType = "application/json";
            watch.Stop();
            var elapsedMs = watch.ElapsedMilliseconds;

            elapsedMs             = elapsedMs / 1000;
            result.ElapsedTime    = elapsedMs.ToString();
            result.HttpStatusCode = Response.StatusCode.ToString();
            var messaje = JsonConvert.SerializeObject(result, Formatting.Indented);

            logger.Info("Leaving UpdateProject API");
            //return Json(messaje);
            return(Content(messaje));
        }
        public ActionResult DeleteProject(int projectID)
        {
            var watch = System.Diagnostics.Stopwatch.StartNew();

            GlobalVars.ResultGeneric result = new GlobalVars.ResultGeneric()
            {
                Message    = "",
                ReturnCode = 0,
                //ReturnValue = ""
            };
            try
            {
                // Projectr ID is a Required Field
                if (projectID == 0)
                {
                    Response.StatusCode = (int)HttpStatusCode.BadRequest;
                    result.ReturnCode   = -1;
                    result.Message      = "Project ID is a required field.";
                    logger.Warn(result.Message);
                }
                else
                {
                    logger.Info("DeleteProject API Request. Project ID: " + projectID);
                    result = SQLFunctionsProjects.DeleteProject(projectID);

                    switch (result.ReturnCode)
                    {
                    case 0:
                        // DeleteProject ends successfully
                        logger.Info("Project ID:  " + projectID + " was Deleted Successfully.");
                        result.Message      = "Project ID:  " + projectID + " was Deleted Successfully.";
                        Response.StatusCode = (int)HttpStatusCode.OK;
                        break;

                    case -1:
                        logger.Info("DeleteProject API Request ends with a warning.");
                        Response.StatusCode = (int)HttpStatusCode.OK;
                        break;

                    case -2:
                        // DeleteProject ends with a Fatal error
                        logger.Fatal("DeleteProject API Request ends with a Fatal Error.");
                        logger.Debug("Returned value:" + JsonConvert.SerializeObject(result, Formatting.Indented));
                        Response.StatusCode = (int)HttpStatusCode.InternalServerError;
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                logger.Fatal("DeleteProject API Request ends with a Fatal Error.");
                System.Diagnostics.Trace.WriteLineIf(true, "Error:" + e.Message + "\n" + "Exception: " + e.InnerException);
                result.ReturnCode = -2;
                result.Message    = e.Message;
                var baseException = e.GetBaseException();
                result.Exception = baseException.ToString();
                logger.Fatal("Returned value:" + JsonConvert.SerializeObject(result, Formatting.Indented));
                Response.StatusCode = (int)HttpStatusCode.InternalServerError;
            }
            Response.ContentType = "application/json";
            watch.Stop();
            var elapsedMs = watch.ElapsedMilliseconds;

            elapsedMs             = elapsedMs / 1000;
            result.ElapsedTime    = elapsedMs.ToString();
            result.HttpStatusCode = Response.StatusCode.ToString();
            var messaje = JsonConvert.SerializeObject(result, Formatting.Indented);

            logger.Info("Leaving DeleteProject API");
            //return Json(messaje);
            return(Content(messaje));
        }