Ejemplo n.º 1
0
        public IHttpActionResult CreateCompany(CompanyModel.Format_Create company)
        {
            string logForm = "Form : " + JsonConvert.SerializeObject(company);
            string logAPI  = "[Post] " + Request.RequestUri.ToString();

            if (!ModelState.IsValid || company == null)
            {
                Global._appLogger.Warn(logAPI + " || Input Parameter not expected || " + logForm);
                return(Content(HttpStatusCode.BadRequest, HttpResponseFormat.InvaildData()));
            }

            try
            {
                CompanyModel companyModel = new CompanyModel();
                int          id           = companyModel.Create(company);
                return(Content(HttpStatusCode.OK, HttpResponseFormat.Success(id)));
            }
            catch (Exception ex)
            {
                StringBuilder logMessage = LogHelper.BuildExceptionMessage(ex);
                logMessage.AppendLine(logForm);
                Global._appLogger.Error(logAPI + logMessage);

                return(Content(HttpStatusCode.InternalServerError, ex));
            }
        }