Пример #1
0
        public IHttpActionResult EditFormData(int id, [FromBody] MessageMandatoryElementDefModels.Update IoTHub)
        {
            JavaScriptSerializer js = new JavaScriptSerializer();
            string logForm          = "Form : " + js.Serialize(IoTHub);
            string logAPI           = "[Put] " + Request.RequestUri.ToString();

            if (!ModelState.IsValid || IoTHub == null)
            {
                Startup._sfAppLogger.Warn(logAPI + " || Input Parameter not expected || " + logForm);
                return(BadRequest("Invalid data"));
            }

            try
            {
                MessageMandatoryElementDefModels mMEDModel = new MessageMandatoryElementDefModels();
                mMEDModel.updateMessageMandatoryElementDef(id, IoTHub);
                return(Ok("Success"));
            }
            catch (Exception ex)
            {
                StringBuilder logMessage = LogUtility.BuildExceptionMessage(ex);
                logMessage.AppendLine(logForm);
                Startup._sfAppLogger.Error(logAPI + logMessage);

                return(InternalServerError(ex));
            }
        }
Пример #2
0
        public IHttpActionResult AddFormData([FromBody] MessageMandatoryElementDefModels.Add IoTHub)
        {
            string logForm = "Form : " + Startup._jsSerializer.Serialize(IoTHub);
            string logAPI  = "[Post] " + Request.RequestUri.ToString();

            if (!ModelState.IsValid || IoTHub == null)
            {
                Startup._sfAppLogger.Warn(logAPI + " || Input Parameter not expected || " + logForm);
                return(BadRequest("Invalid data"));
            }

            try
            {
                MessageMandatoryElementDefModels mMEDModel = new MessageMandatoryElementDefModels();
                mMEDModel.addMessageMandatoryElementDef(IoTHub);
                return(Ok());
            }
            catch (Exception ex)
            {
                StringBuilder logMessage = LogUtility.BuildExceptionMessage(ex);
                logMessage.AppendLine(logForm);
                Startup._sfAppLogger.Error(logAPI + logMessage);

                return(InternalServerError(ex));
            }
        }
Пример #3
0
 public IHttpActionResult GetMessageMandatoryElementDefById(int id)
 {
     try
     {
         MessageMandatoryElementDefModels mMEDModel = new MessageMandatoryElementDefModels();
         return(Ok(mMEDModel.getMessageMandatoryElementDefById(id)));
     }
     catch
     {
         return(NotFound());
     }
 }
Пример #4
0
 public IHttpActionResult Delete(int id)
 {
     try
     {
         MessageMandatoryElementDefModels mMEDModel = new MessageMandatoryElementDefModels();
         mMEDModel.deleteMessageMandatoryElementDef(id);
         return(Ok("Success"));
     }
     catch (Exception ex)
     {
         string        logAPI     = "[Delete] " + Request.RequestUri.ToString();
         StringBuilder logMessage = LogUtility.BuildExceptionMessage(ex);
         Startup._sfAppLogger.Error(logAPI + logMessage);
         return(InternalServerError());
     }
 }