Esempio n. 1
0
        public int create(mediaCarrier carrier, string username, string password)
        {
            Authenticate(username, password);

            if (carrier == null) throw new Exception("No carrier specified");
            if (carrier.ParentId == 0) throw new Exception("Media needs a parent");
            if (carrier.TypeId == 0) throw new Exception("Type must be specified");
            if (carrier.Text == null || carrier.Text.Length == 0) carrier.Text = "unnamed";

            BusinessLogic.User user = GetUser(username, password);

            var mt = new MediaType(carrier.TypeId);
            var m = Media.MakeNew(carrier.Text, mt, user, carrier.ParentId);

            if (carrier.MediaProperties != null)
            {
                foreach (mediaProperty updatedproperty in carrier.MediaProperties)
                {
                    if (!(updatedproperty.Key.ToLower().Equals("umbracofile")))
                    {
                        Property property = m.getProperty(updatedproperty.Key);
                        if (property == null)
                            throw new Exception("property " + updatedproperty.Key + " was not found");
                        property.Value = updatedproperty.PropertyValue;
                    }
                }
            }

            return m.Id;
        }
Esempio n. 2
0
        public void update(mediaCarrier carrier, string username, string password)
        {
            Authenticate(username, password);

            if (carrier == null)
            {
                throw new Exception("No carrier specified");
            }

            Media m = new Media(carrier.Id);

            if (carrier.MediaProperties != null)
            {
                foreach (mediaProperty updatedproperty in carrier.MediaProperties)
                {
                    if (!(updatedproperty.Key.ToLower().Equals("umbracofile")))
                    {
                        Property property = m.getProperty(updatedproperty.Key);
                        if (property == null)
                        {
                            throw new Exception("property " + updatedproperty.Key + " was not found");
                        }
                        property.Value = updatedproperty.PropertyValue;
                    }
                }
            }

            m.Save();
        }
Esempio n. 3
0
        public void update(mediaCarrier carrier, string username, string password)
        {

            Authenticate(username, password);

            if (carrier == null) throw new Exception("No carrier specified");

            Media m = new Media(carrier.Id);

            if (carrier.MediaProperties != null)
            {
                foreach (mediaProperty updatedproperty in carrier.MediaProperties)
                {
                    if (!(updatedproperty.Key.ToLower().Equals("umbracofile")))
                    {
                        Property property = m.getProperty(updatedproperty.Key);
                        if (property == null)
                            throw new Exception("property " + updatedproperty.Key + " was not found");
                        property.Value = updatedproperty.PropertyValue;
                    }
                }
            }

            m.Save();
        }
Esempio n. 4
0
        public int create(mediaCarrier carrier, string username, string password)
        {
            Authenticate(username, password);

            if (carrier == null)
            {
                throw new Exception("No carrier specified");
            }
            if (carrier.ParentId == 0)
            {
                throw new Exception("Media needs a parent");
            }
            if (carrier.TypeId == 0)
            {
                throw new Exception("Type must be specified");
            }
            if (carrier.Text == null || carrier.Text.Length == 0)
            {
                carrier.Text = "unnamed";
            }

            umbraco.BusinessLogic.User user = GetUser(username, password);


            MediaType mt = new MediaType(carrier.TypeId);

            Media m = Media.MakeNew(carrier.Text, mt, user, carrier.ParentId);

            if (carrier.MediaProperties != null)
            {
                foreach (mediaProperty updatedproperty in carrier.MediaProperties)
                {
                    if (!(updatedproperty.Key.ToLower().Equals("umbracofile")))
                    {
                        Property property = m.getProperty(updatedproperty.Key);
                        if (property == null)
                        {
                            throw new Exception("property " + updatedproperty.Key + " was not found");
                        }
                        property.Value = updatedproperty.PropertyValue;
                    }
                }
            }

            return(m.Id);
        }
Esempio n. 5
0
        private mediaCarrier createCarrier(Media m)
        {
            mediaCarrier carrier = new mediaCarrier();

            carrier.Id   = m.Id;
            carrier.Text = m.Text;

            carrier.TypeAlias = m.ContentType.Alias;
            carrier.TypeId    = m.ContentType.Id;

            carrier.CreateDateTime = m.CreateDateTime;
            carrier.HasChildren    = m.HasChildren;
            carrier.Level          = m.Level;

            carrier.Path      = m.Path;
            carrier.SortOrder = m.sortOrder;

            try
            {
                carrier.ParentId = m.Parent.Id;
            }
            catch
            {
                carrier.ParentId = -1;
            }

            foreach (Property p in m.getProperties)
            {
                mediaProperty carrierprop = new mediaProperty();

                if (p.Value == System.DBNull.Value)
                {
                    carrierprop.PropertyValue = "";
                }
                else
                {
                    carrierprop.PropertyValue = p.Value;
                }

                carrierprop.Key = p.PropertyType.Alias;
                carrier.MediaProperties.Add(carrierprop);
            }

            return(carrier);
        }
Esempio n. 6
0
        private mediaCarrier createCarrier(Media m)
        {
            var carrier = new mediaCarrier
            {
                Id             = m.Id,
                Text           = m.Text,
                TypeAlias      = m.ContentType.Alias,
                TypeId         = m.ContentType.Id,
                CreateDateTime = m.CreateDateTime,
                HasChildren    = m.HasChildren,
                Level          = m.Level,
                Path           = m.Path,
                SortOrder      = m.sortOrder
            };

            try
            {
                carrier.ParentId = m.Parent.Id;
            }
            catch
            {
                carrier.ParentId = -1;
            }

            foreach (Property p in m.GenericProperties)
            {
                var carrierprop = new mediaProperty();

                if (p.Value == DBNull.Value)
                {
                    carrierprop.PropertyValue = "";
                }
                else
                {
                    carrierprop.PropertyValue = p.Value;
                }

                carrierprop.Key = p.PropertyType.Alias;
                carrier.MediaProperties.Add(carrierprop);
            }

            return(carrier);
        }
Esempio n. 7
0
        private mediaCarrier createCarrier(Media m)
        {
            var carrier = new mediaCarrier
                              {
                                  Id = m.Id,
                                  Text = m.Text,
                                  TypeAlias = m.ContentType.Alias,
                                  TypeId = m.ContentType.Id,
                                  CreateDateTime = m.CreateDateTime,
                                  HasChildren = m.HasChildren,
                                  Level = m.Level,
                                  Path = m.Path,
                                  SortOrder = m.sortOrder
                              };

            try
            {
                carrier.ParentId = m.Parent.Id;
            }
            catch
            {
                carrier.ParentId = -1;
            }

            foreach (Property p in m.GenericProperties)
            {
                var carrierprop = new mediaProperty();

                if (p.Value == DBNull.Value)
                {
                    carrierprop.PropertyValue = "";
                }
                else
                {
                    carrierprop.PropertyValue = p.Value;
                }

                carrierprop.Key = p.PropertyType.Alias;
                carrier.MediaProperties.Add(carrierprop);

            }

            return carrier;
        }
Esempio n. 8
0
        private mediaCarrier createCarrier(Media m)
        {
            mediaCarrier carrier = new mediaCarrier();
            carrier.Id = m.Id;
            carrier.Text = m.Text;

            carrier.TypeAlias = m.ContentType.Alias;
            carrier.TypeId = m.ContentType.Id;

            carrier.CreateDateTime = m.CreateDateTime;
            carrier.HasChildren = m.HasChildren;
            carrier.Level = m.Level;

            carrier.Path = m.Path;
            carrier.SortOrder = m.sortOrder;

            try
            {
                carrier.ParentId = m.Parent.Id;
            }
            catch
            {
                carrier.ParentId = -1;
            }

            foreach (Property p in m.getProperties)
            {

                mediaProperty carrierprop = new mediaProperty();

                if (p.Value == System.DBNull.Value)
                {
                    carrierprop.PropertyValue = "";
                }
                else
                {
                    carrierprop.PropertyValue = p.Value;
                }

                carrierprop.Key = p.PropertyType.Alias;
                carrier.MediaProperties.Add(carrierprop);

            }

            return carrier;
        }