Exemplo n.º 1
0
        public IHttpActionResult CreateApplication([FromBody] ApplicationModel.Format_Create dataModel)
        {
            string logForm = "Form : " + JsonConvert.SerializeObject(dataModel);
            string logAPI  = "[Post] " + Request.RequestUri.ToString();

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

            try
            {
                int companyId          = Global.GetCompanyIdFromToken();
                ApplicationModel model = new ApplicationModel();
                int id = model.Create(companyId, dataModel);
                return(Content(HttpStatusCode.OK, HttpResponseFormat.Success(id)));
            }
            catch (CDSException cdsEx)
            {
                return(Content(HttpStatusCode.BadRequest, CDSException.GetCDSErrorMessageByCode(cdsEx.ErrorId)));
            }
            catch (Exception ex)
            {
                StringBuilder logMessage = LogHelper.BuildExceptionMessage(ex);
                logMessage.AppendLine(logForm);
                Global._appLogger.Error(logAPI + logMessage);

                return(Content(HttpStatusCode.InternalServerError, ex));
            }
        }
Exemplo n.º 2
0
        private static ApplicationModel CreateApplicationModel(IServiceProvider s)
        {
            var hypermediaOptions = s.GetRequiredService <HypermediaExtensionsOptions>();

            return(ApplicationModel.Create(hypermediaOptions.ControllerAndHypermediaAssemblies));
        }
 public override void When()
 {
     applicationModel = ApplicationModel.Create(new [] { typeof(BaseHmo).GetTypeInfo().Assembly });
 }