public HttpResponseMessage Post([FromBody] CustomField item)
    {
        try
        {
            if (item == null)
            {
                throw new ApplicationException("Custom field is required");
            }

            item.BlogId = BlogEngine.Core.Blog.CurrentInstance.Id;

            if (item.CustomType == "PROFILE")
            {
                item.ObjectId = BlogEngine.Core.Security.CurrentUser.Identity.Name;
            }

            var result = repository.Add(item);
            if (result == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            return(Request.CreateResponse(HttpStatusCode.Created, result));
        }
        catch (UnauthorizedAccessException)
        {
            return(Request.CreateResponse(HttpStatusCode.Unauthorized));
        }
        catch (Exception)
        {
            return(Request.CreateResponse(HttpStatusCode.InternalServerError));
        }
    }
        public static void DefineCustomFieldType(ICustomFieldRepository customFieldRepository, string name,
                                                 string dictionaryName, int min, int max, EntityTypeEnum entityType)
        {
            var customfieldType = new CustomFieldType(customFieldRepository.GetNextId(),
                                                      name, dictionaryName, min, max, entityType, "string");

            customFieldRepository.Add(customfieldType);
            DefinedCustomFields.Add(customfieldType);
        }
    public HttpResponseMessage Post([FromBody] CustomField item)
    {
        try
        {
            var result = repository.Add(item);
            if (result == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            return(Request.CreateResponse(HttpStatusCode.Created, result));
        }
        catch (UnauthorizedAccessException)
        {
            return(Request.CreateResponse(HttpStatusCode.Unauthorized));
        }
        catch (Exception)
        {
            return(Request.CreateResponse(HttpStatusCode.InternalServerError));
        }
    }
Exemple #4
0
 public CustomFieldType AddCustomFieldType(string name, string dictionaryName,
                                           long minValue, long maxValue, int entityId, string typeId)
 {
     try
     {
         using (var scope = new TransactionScope())
         {
             var id = customFieldRep.GetNextId();
             var customFieldType = new CustomFieldType(id, name, dictionaryName, minValue, maxValue, Enumeration.FromValue <EntityTypeEnum>(entityId.ToString()), typeId);
             customFieldRep.Add(customFieldType);
             scope.Complete();
             return(customFieldType);
         }
     }
     catch (Exception exp)
     {
         var res = customFieldRep.TryConvertException(exp);
         if (res == null)
         {
             throw;
         }
         throw res;
     }
 }