Example #1
0
        public static DataObjectGeneric GetGeneric(string externalObjectId)
        {
            WebServiceLogEntry log = new WebServiceLogEntry()
            {
                ServiceType = WebServiceType.REST, ServiceName = "IDataService", Method = "GetGeneric", Parameters = externalObjectId
            };

            try
            {
                DataObjectGeneric dataObject = (DataObjectGeneric)DataServiceHelper.Get(log, externalObjectId, Common.Helper.GetObjectType("Generic").NumericId);
                log.Write(HttpStatusCode.OK.ToString());
                return(dataObject);
            }
            catch (RESTException e)
            {
                log.Message = e.StatusDescription;
                log.Write(e.StatusCode.ToString());
                return(null);
            }
            catch (Exception e)
            {
                Helper.SetResponseStatus(log, HttpStatusCode.InternalServerError, string.Format("Not Found -> {0}", e.Message));
                log.ExtendedMessage = e.StackTrace;
                log.Write();
                return(null);
            }
        }
Example #2
0
        public static DataObjectNews CreateNews(DataObjectNews receivedDataObject)
        {
            WebServiceLogEntry log = new WebServiceLogEntry()
            {
                ServiceType = WebServiceType.REST, ServiceName = "IDataService", Method = "CreateNews", Parameters = "DataObjectNews"
            };

            try
            {
                DataServiceHelper.Create(log, receivedDataObject, Common.Helper.GetObjectType("News").NumericId);
                Helper.GetImages(log, receivedDataObject, null);
                receivedDataObject.Update(UserDataContext.GetUserDataContext(OperationContext.Current.ServiceSecurityContext.PrimaryIdentity.Name));
                if (receivedDataObject.State == ObjectState.Saved)
                {
                    log.Write(HttpStatusCode.OK.ToString());
                    return(receivedDataObject);
                }
                throw new RESTException(HttpStatusCode.NotFound, "Not Updated (specific)");
            }
            catch (RESTException e)
            {
                log.Message = e.StatusDescription;
                log.Write(e.StatusCode.ToString());
                return(null);
            }
            catch (Exception e)
            {
                Helper.SetResponseStatus(log, HttpStatusCode.InternalServerError, string.Format("Not Created -> {0}", e.Message));
                log.ExtendedMessage = e.StackTrace;
                log.Write();
                return(null);
            }
        }