示例#1
0
        public OperationResult Create(DoseRecord doseRecord, Guid processId)
        {
            OperationResult responseObject = new OperationResult();

            try
            {
                var newDose = this.GetCreateDoseJsonStructure(doseRecord, processId);

                responseObject = this.DoseCreateRequest(newDose, processId);
                return(responseObject);
            }
            catch (Exception ex)
            {
                LogEventInfo log = new LogEventInfo(LogLevel.Error, Logger.Name, null, "", null, new Exception(ex.ToString()));
                log.Properties["ProcessID"]  = processId;
                log.Properties["AppID"]      = AboxDynamicsBase.Classes.Constants.ApplicationIdWebAPI;
                log.Properties["MethodName"] = System.Reflection.MethodBase.GetCurrentMethod().Name;
                Logger.Log(log);
                responseObject.Code         = "";
                responseObject.Message      = ex.ToString();
                responseObject.IsSuccessful = false;
                responseObject.Data         = null;
            }

            return(responseObject);
        }
示例#2
0
        private JObject GetCreateDoseJsonStructure(DoseRecord doseRecord, Guid processId)
        {
            OperationResult result        = new OperationResult();
            JObject         jObject       = new JObject();
            ProductEntity   productEntity = new ProductEntity();

            try
            {
                if (!String.IsNullOrEmpty(doseRecord.IdProduct))
                {
                    jObject.Add($"{DoseSchemas.DosexProduct}@odata.bind", new JValue($"/{productEntity.EntityPluralName}({ProductFields.ProductNumber}='{doseRecord.IdProduct}')"));
                }

                if (!String.IsNullOrEmpty(doseRecord.ContactBinding))
                {
                    jObject.Add($"{DoseSchemas.ContactxDose}@odata.bind", new JValue($"/{doseRecord.ContactBinding}"));
                }

                if (!(String.IsNullOrEmpty(doseRecord.Dose)))
                {
                    jObject.Add($"{DoseFields.Dose}", sharedMethods.GetDoseFrequencyValue(doseRecord.Dose));
                }

                return(jObject);
            }
            catch (Exception ex)
            {
                LogEventInfo log = new LogEventInfo(LogLevel.Error, Logger.Name, null, "", null, new Exception(ex.ToString()));
                log.Properties["ProcessID"]  = processId;
                log.Properties["AppID"]      = AboxDynamicsBase.Classes.Constants.ApplicationIdWebAPI;
                log.Properties["MethodName"] = System.Reflection.MethodBase.GetCurrentMethod().Name;
                Logger.Log(log);

                jObject = null;
                return(jObject);
            }
        }