Ejemplo n.º 1
0
        public IHttpActionResult GetCompanyById()
        {
            int      companyId  = Global.GetCompanyIdFromToken();
            RedisKey cacheKey   = "external_company_" + companyId;
            string   cacheValue = null;// RedisCacheHelper.GetValueByKey(cacheKey);

            if (cacheValue == null)
            {
                try
                {
                    CompanyModel model = new CompanyModel();
                    //RedisCacheHelper.SetKeyValue(cacheKey, JsonConvert.SerializeObject(company));
                    return(Content(HttpStatusCode.OK, model.GetCompanyByIdForExternal(UserToken.CompanyId)));
                }
                catch (CDSException cdsEx)
                {
                    return(Content(HttpStatusCode.BadRequest, CDSException.GetCDSErrorMessageByCode(cdsEx.ErrorId)));
                }
                catch (Exception ex)
                {
                    return(Content(HttpStatusCode.InternalServerError, ex));
                }
            }
            else
            {
                return(Ok(new JavaScriptSerializer().Deserialize <Object>(cacheValue)));
            }
        }
Ejemplo n.º 2
0
        public IHttpActionResult CreateSuperAdmin([FromBody] SuperAdminModel.Format_Create SuperAdmin)
        {
            string logForm = "Form : " + JsonConvert.SerializeObject(SuperAdmin);
            string logAPI  = "[Post] " + Request.RequestUri.ToString();

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

            try
            {
                SuperAdminModel model = new SuperAdminModel();
                int             id    = model.Create(SuperAdmin);
                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));
            }
        }
Ejemplo n.º 3
0
        public IHttpActionResult UpdateFactory(int id, [FromBody] FactoryModel.Format_Update factory)
        {
            string logForm = "Form : " + JsonConvert.SerializeObject(factory);
            string logAPI  = "[Patch] " + Request.RequestUri.ToString();

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

            FactoryModel factoryModel = new FactoryModel();

            try
            {
                factoryModel.Update(id, factory);
                return(Content(HttpStatusCode.OK, HttpResponseFormat.Success()));
            }
            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));
            }
        }
Ejemplo n.º 4
0
        public IHttpActionResult AddRolesByEmployeeId(int id, [FromBody] EmployeeInRoleModel.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()));
            }
            else
            {
                try
                {
                    EmployeeInRoleModel model = new EmployeeInRoleModel();
                    model.CreateManyByEmployeeId(id, dataModel.UserRoleIdList);
                    return(Content(HttpStatusCode.OK, model.GetAllByEmployeeId(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));
                }
            }
        }
Ejemplo n.º 5
0
        public IHttpActionResult UpdateSubscription(int id, int subscriptionId, [FromBody] CompanyInSubscriptionPlanModel.Format_Update dataModel)
        {
            string logForm = "Form : " + JsonConvert.SerializeObject(dataModel);
            string logAPI  = "[Put] " + Request.RequestUri.ToString();

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

            try
            {
                CompanyInSubscriptionPlanModel model = new CompanyInSubscriptionPlanModel();
                model.Update(id, subscriptionId, dataModel);
                //RedisCacheHelper.DeleteCompanyCache(id);
                return(Content(HttpStatusCode.OK, HttpResponseFormat.Success()));
            }
            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));
            }
        }
Ejemplo n.º 6
0
        public HttpResponseMessage GetAllowDomainByCompanyId(int id)
        {
            RedisKey cacheKey   = "company_" + id + "_allowDomain";
            string   cacheValue = null;

            if (Global._enableRedisCache)
            {
                cacheValue = RedisCacheHelper.GetValueByKey(cacheKey);
            }

            if (cacheValue == null)
            {
                CompanyModel companyModel = new Models.CompanyModel();
                try
                {
                    CompanyModel.Format_Detail company = companyModel.GetById(id);
                    //RedisCacheHelper.SetKeyValue(cacheKey, new JavaScriptSerializer().Serialize(company));
                    return(Request.CreateResponse(HttpStatusCode.OK, company.AllowDomain));
                }
                catch (CDSException cdsEx)
                {
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, CDSException.GetCDSErrorMessageByCode(cdsEx.ErrorId)));
                }
                catch (Exception ex)
                {
                    return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex));
                }
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.OK, JsonConvert.DeserializeObject <CompanyModel.Format_Detail>(cacheValue).AllowDomain));
            }
        }
Ejemplo n.º 7
0
        public IHttpActionResult EditRolesByEmployeeId(int id, [FromBody] EmployeeInRoleModel.Format_Update dataModel)
        {
            string logForm = "Form : " + JsonConvert.SerializeObject(dataModel);
            string logAPI  = "[Put] " + Request.RequestUri.ToString();

            try
            {
                EmployeeInRoleModel model = new EmployeeInRoleModel();
                model.DeleteAllByEmployeeId(id);

                if (dataModel != null && dataModel.UserRoleIdList.Count > 0)
                {
                    model.CreateManyByEmployeeId(id, dataModel.UserRoleIdList);
                }
                return(Content(HttpStatusCode.OK, HttpResponseFormat.Success()));
            }
            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));
            }
        }
Ejemplo n.º 8
0
        public IHttpActionResult GetCompanyById(int id)
        {
            RedisKey cacheKey   = "company_" + id;
            string   cacheValue = null;

            if (Global._enableRedisCache)
            {
                cacheValue = RedisCacheHelper.GetValueByKey(cacheKey);
            }
            if (cacheValue == null)
            {
                CompanyModel companyModel = new CompanyModel();
                try
                {
                    CompanyModel.Format_Detail company = companyModel.GetById(id);
                    //RedisCacheHelper.SetKeyValue(cacheKey, JsonConvert.SerializeObject(company));
                    return(Content(HttpStatusCode.OK, company));
                }
                catch (CDSException cdsEx)
                {
                    return(Content(HttpStatusCode.BadRequest, CDSException.GetCDSErrorMessageByCode(cdsEx.ErrorId)));
                }
                catch (Exception ex)
                {
                    return(Content(HttpStatusCode.InternalServerError, ex));
                }
            }
            else
            {
                return(Content(HttpStatusCode.OK, JsonConvert.DeserializeObject(cacheValue)));
            }
        }
Ejemplo n.º 9
0
        public IHttpActionResult UpdateDeviceCommand(int id, [FromBody] IoTDeviceCommandModel.Format_UpdateByIoTDevice dataModel)
        {
            string logForm = "Form : " + JsonConvert.SerializeObject(dataModel);
            string logAPI  = "[Post] " + Request.RequestUri.ToString();

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

            try
            {
                IoTDeviceCommandModel model = new IoTDeviceCommandModel();
                model.UpdateByIoTDevieId(id, dataModel);
                return(Content(HttpStatusCode.OK, HttpResponseFormat.Success()));
            }
            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));
            }
        }
Ejemplo n.º 10
0
        public IHttpActionResult GetEmployeeById(int id)
        {
            RedisKey cacheKey   = "employee_" + id;
            string   cacheValue = null;

            if (Global._enableRedisCache)
            {
                cacheValue = RedisCacheHelper.GetValueByKey(cacheKey);
            }

            if (cacheValue == null)
            {
                try
                {
                    EmployeeModel model    = new EmployeeModel();
                    var           employee = model.GetById(id);
                    //RedisCacheHelper.SetKeyValue(cacheKey, new JavaScriptSerializer().Serialize(employee));
                    return(Content(HttpStatusCode.OK, employee));
                }
                catch (CDSException cdsEx)
                {
                    return(Content(HttpStatusCode.BadRequest, CDSException.GetCDSErrorMessageByCode(cdsEx.ErrorId)));
                }
                catch (Exception ex)
                {
                    return(Content(HttpStatusCode.InternalServerError, ex));
                }
            }
            else
            {
                return(Ok(JsonConvert.DeserializeObject <Object>(cacheValue)));
            }
        }
Ejemplo n.º 11
0
        public IHttpActionResult GetRolesByEmployeeId(int id)
        {
            RedisKey cacheKey   = "employee_" + id + "_Role";
            string   cacheValue = null;

            if (Global._enableRedisCache)
            {
                cacheValue = RedisCacheHelper.GetValueByKey(cacheKey);
            }

            if (cacheValue == null)
            {
                try
                {
                    EmployeeInRoleModel model = new EmployeeInRoleModel();
                    model.GetAllByEmployeeId(id);
                    return(Content(HttpStatusCode.OK, model.GetAllByEmployeeId(id)));
                }
                catch (CDSException cdsEx)
                {
                    return(Content(HttpStatusCode.BadRequest, CDSException.GetCDSErrorMessageByCode(cdsEx.ErrorId)));
                }
                catch (Exception ex)
                {
                    return(Content(HttpStatusCode.InternalServerError, ex));
                }
            }
            else
            {
                return(Content(HttpStatusCode.OK, JsonConvert.DeserializeObject <List <Object> >(cacheValue)));
            }
        }
Ejemplo n.º 12
0
        public IHttpActionResult ChangeEmployeePassword(int id, [FromBody] PasswordModel.Format_Change dataModel)
        {
            string logForm = "Form : " + JsonConvert.SerializeObject(dataModel);
            string logAPI  = "[Put] " + Request.RequestUri.ToString();

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

            try
            {
                EmployeeModel model = new EmployeeModel();
                model.ChangePassword(id, dataModel);
                return(Content(HttpStatusCode.OK, HttpResponseFormat.Success()));
            }
            catch (CDSException cdsEx)
            {
                return(Content(HttpStatusCode.Unauthorized, 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));
            }
        }
Ejemplo n.º 13
0
        public IHttpActionResult GetAlarmMessageByEquipmentId(int equipmentId, [FromUri] int top = 10, [FromUri] int hours = 168, [FromUri] string order = "desc")
        {
            try
            {
                EquipmentModels        equipmentModel = new EquipmentModels();
                EquipmentModels.Detail equipment      = equipmentModel.getEquipmentById(equipmentId);
                CompanyModel           companyModel   = new CompanyModel();
                var companySubscription       = companyModel.GetValidSubscriptionPlanByCompanyId(equipment.CompanyId);
                DocumentDBHelper docDBHelpler = new DocumentDBHelper(equipment.CompanyId, companySubscription.CosmosDBConnectionString);
                return(Ok(docDBHelpler.GetAlarmMessageByEquipmentId(equipment.EquipmentId, top, hours, order)));
            }
            catch (CDSException cdsEx)
            {
                IHttpActionResult   response;
                HttpResponseMessage responseMsg = new HttpResponseMessage(HttpStatusCode.BadRequest);
                string body = new JavaScriptSerializer().Serialize(CDSException.GetCDSErrorMessageByCode(cdsEx.ErrorId));
                responseMsg.Content = new StringContent(body, Encoding.UTF8, "application/json");
                response            = ResponseMessage(responseMsg);
                return(response);
            }
            catch (Exception ex)
            {
                StringBuilder logMessage = LogHelper.BuildExceptionMessage(ex);
                string        logAPI     = "[Get] " + Request.RequestUri.ToString();
                Global._appLogger.Error(logAPI + logMessage);

                return(Content(HttpStatusCode.InternalServerError, ex));
            }
        }
Ejemplo n.º 14
0
        public IHttpActionResult DeleteCompany([FromUri] int companyId, [FromBody] BackendTaskModel.Format_Base dataModel)
        {
            string logForm = "Form : " + JsonConvert.SerializeObject(dataModel);
            string logAPI  = "[Delete] " + Request.RequestUri.ToString();

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

            try
            {
                BackendTaskModel model = new BackendTaskModel();
                model.DeleteCompanyCosmosDBCollection(companyId, dataModel);
                return(Content(HttpStatusCode.OK, HttpResponseFormat.Success()));
            }
            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));
            }
        }
Ejemplo n.º 15
0
 public IHttpActionResult GetIoTDeviceById(int iotDeviceId)
 {
     try
     {
         IoTDeviceModel model = new IoTDeviceModel();
         return(Content(HttpStatusCode.OK, model.External_GetById(iotDeviceId, UserToken.CompanyId)));
     }
     catch (CDSException cdsEx)
     {
         return(Content(HttpStatusCode.BadRequest, CDSException.GetCDSErrorMessageByCode(cdsEx.ErrorId)));
     }
     catch (Exception ex)
     {
         return(Content(HttpStatusCode.InternalServerError, ex));
     }
 }
Ejemplo n.º 16
0
 public IHttpActionResult GetAllRules(int id)
 {
     try
     {
         EventRuleItemModel model = new EventRuleItemModel();
         return(Ok(model.GetAllByEventRuleCatalogId(id)));
     }
     catch (CDSException cdsEx)
     {
         return(Content(HttpStatusCode.BadRequest, CDSException.GetCDSErrorMessageByCode(cdsEx.ErrorId)));
     }
     catch (Exception ex)
     {
         return(Content(HttpStatusCode.InternalServerError, ex));
     }
 }
Ejemplo n.º 17
0
 public IHttpActionResult GetAllEquipmentByFactoryId(int factoryId, [FromUri] bool metaData = false)
 {
     try
     {
         EquipmentModel model = new EquipmentModel();
         return(Content(HttpStatusCode.OK, model.External_GetAllByFactoryId(factoryId, metaData, UserToken.CompanyId)));
     }
     catch (CDSException cdsEx)
     {
         return(Content(HttpStatusCode.BadRequest, CDSException.GetCDSErrorMessageByCode(cdsEx.ErrorId)));
     }
     catch (Exception ex)
     {
         return(Content(HttpStatusCode.InternalServerError, ex));
     }
 }
Ejemplo n.º 18
0
 public IHttpActionResult GetSubscriptionByCompanyId(int id, int subscriptionId)
 {
     try
     {
         CompanyInSubscriptionPlanModel model = new CompanyInSubscriptionPlanModel();
         return(Content(HttpStatusCode.OK, model.Get(id, subscriptionId)));
     }
     catch (CDSException cdsEx)
     {
         return(Content(HttpStatusCode.BadRequest, CDSException.GetCDSErrorMessageByCode(cdsEx.ErrorId)));
     }
     catch (Exception ex)
     {
         return(Content(HttpStatusCode.InternalServerError, ex));
     }
 }
Ejemplo n.º 19
0
 public IHttpActionResult GetMetaDataDefinationById(int id)
 {
     try
     {
         MetaDataDefinationModel model = new MetaDataDefinationModel();
         return(Content(HttpStatusCode.OK, model.GetById(id, UserToken.CompanyId)));
     }
     catch (CDSException cdsEx)
     {
         return(Content(HttpStatusCode.BadRequest, CDSException.GetCDSErrorMessageByCode(cdsEx.ErrorId)));
     }
     catch (Exception ex)
     {
         return(Content(HttpStatusCode.InternalServerError, ex));
     }
 }
 public IHttpActionResult GetMessageMandatoryElementDefById(int id)
 {
     try
     {
         MessageMandatoryElementDefModel model = new MessageMandatoryElementDefModel();
         return(Content(HttpStatusCode.OK, model.GetById(id)));
     }
     catch (CDSException cdsEx)
     {
         return(Content(HttpStatusCode.BadRequest, CDSException.GetCDSErrorMessageByCode(cdsEx.ErrorId)));
     }
     catch (Exception ex)
     {
         return(Content(HttpStatusCode.InternalServerError, ex));
     }
 }
 public IHttpActionResult GetIoTDeviceSystemConfigurationById(int id)
 {
     try
     {
         IoTDeviceSystemConfigurationModel model = new IoTDeviceSystemConfigurationModel();
         return(Content(HttpStatusCode.OK, model.GetById(id)));
     }
     catch (CDSException cdsEx)
     {
         return(Content(HttpStatusCode.BadRequest, CDSException.GetCDSErrorMessageByCode(cdsEx.ErrorId)));
     }
     catch (Exception ex)
     {
         return(Content(HttpStatusCode.InternalServerError, ex));
     }
 }
 public IHttpActionResult GetDeviceCommandCatalogById(int id)
 {
     try
     {
         DeviceCommandCatalogModel model = new DeviceCommandCatalogModel();
         return(Content(HttpStatusCode.OK, model.GetById(id)));
     }
     catch (CDSException cdsEx)
     {
         return(Content(HttpStatusCode.BadRequest, CDSException.GetCDSErrorMessageByCode(cdsEx.ErrorId)));
     }
     catch (Exception ex)
     {
         return(Content(HttpStatusCode.InternalServerError, ex));
     }
 }
Ejemplo n.º 23
0
 public IHttpActionResult GetEquipmentClassById(int id)
 {
     try
     {
         EquipmentClassModel model = new EquipmentClassModel();
         return(Content(HttpStatusCode.OK, model.GetById(id)));
     }
     catch (CDSException cdsEx)
     {
         return(Content(HttpStatusCode.BadRequest, CDSException.GetCDSErrorMessageByCode(cdsEx.ErrorId)));
     }
     catch (Exception ex)
     {
         return(Content(HttpStatusCode.InternalServerError, ex));
     }
 }
Ejemplo n.º 24
0
 public IHttpActionResult GetUserRoleById(int id)
 {
     try
     {
         UserRoleModel model = new UserRoleModel();
         return(Ok(model.GetById(id)));
     }
     catch (CDSException cdsEx)
     {
         return(Content(HttpStatusCode.BadRequest, CDSException.GetCDSErrorMessageByCode(cdsEx.ErrorId)));
     }
     catch (Exception ex)
     {
         return(Content(HttpStatusCode.InternalServerError, ex));
     }
 }
Ejemplo n.º 25
0
 public IHttpActionResult GetExternalDashboardById(int id, int externalDashboardId)
 {
     try
     {
         ExternalDashboardModel model = new ExternalDashboardModel();
         return(Content(HttpStatusCode.OK, model.GetById(externalDashboardId, id)));
     }
     catch (CDSException cdsEx)
     {
         return(Content(HttpStatusCode.BadRequest, CDSException.GetCDSErrorMessageByCode(cdsEx.ErrorId)));
     }
     catch (Exception ex)
     {
         return(Content(HttpStatusCode.InternalServerError, ex));
     }
 }
        public IHttpActionResult GetPermissionCatalogByCode(int code)
        {
            try
            {
                PermissionCatalogModel model = new PermissionCatalogModel();

                return(Content(HttpStatusCode.OK, model.GetByCode(code)));
            }
            catch (CDSException cdsEx)
            {
                return(Content(HttpStatusCode.BadRequest, CDSException.GetCDSErrorMessageByCode(cdsEx.ErrorId)));
            }
            catch (Exception ex)
            {
                return(Content(HttpStatusCode.InternalServerError, ex));
            }
        }
Ejemplo n.º 27
0
 public IHttpActionResult GetSuperAdminById(int id)
 {
     try
     {
         SuperAdminModel model      = new SuperAdminModel();
         var             SuperAdmin = model.GetById(id);
         return(Content(HttpStatusCode.OK, SuperAdmin));
     }
     catch (CDSException cdsEx)
     {
         return(Content(HttpStatusCode.BadRequest, CDSException.GetCDSErrorMessageByCode(cdsEx.ErrorId)));
     }
     catch (Exception ex)
     {
         return(Content(HttpStatusCode.InternalServerError, ex));
     }
 }
Ejemplo n.º 28
0
 public IHttpActionResult GetEventRuleCatalogByCompanyId()
 {
     try
     {
         int companyId = Global.GetCompanyIdFromToken();
         EventRuleCatalogModel model = new EventRuleCatalogModel();
         return(Content(HttpStatusCode.OK, model.GetAllByCompanyId(companyId)));
     }
     catch (CDSException cdsEx)
     {
         return(Content(HttpStatusCode.BadRequest, CDSException.GetCDSErrorMessageByCode(cdsEx.ErrorId)));
     }
     catch (Exception ex)
     {
         return(Content(HttpStatusCode.InternalServerError, ex));
     }
 }
Ejemplo n.º 29
0
 public IHttpActionResult GetFactoryById(int factoryId)
 {
     try
     {
         FactoryModel model = new FactoryModel();
         //RedisCacheHelper.SetKeyValue(cacheKey, JsonConvert.SerializeObject(company));
         return(Content(HttpStatusCode.OK, model.External_GetById(factoryId, UserToken.CompanyId)));
     }
     catch (CDSException cdsEx)
     {
         return(Content(HttpStatusCode.BadRequest, CDSException.GetCDSErrorMessageByCode(cdsEx.ErrorId)));
     }
     catch (Exception ex)
     {
         return(Content(HttpStatusCode.InternalServerError, ex));
     }
 }
Ejemplo n.º 30
0
        public IHttpActionResult GetAllCompanies()
        {
            CompanyModel companyModel = new CompanyModel();

            try
            {
                return(Content(HttpStatusCode.OK, companyModel.GetAll()));
            }
            catch (CDSException cdsEx)
            {
                return(Content(HttpStatusCode.BadRequest, CDSException.GetCDSErrorMessageByCode(cdsEx.ErrorId)));
            }
            catch (Exception ex)
            {
                return(Content(HttpStatusCode.InternalServerError, ex));
            }
        }