Ejemplo n.º 1
0
        public virtual ContentResult SetRowImages(string rowsViewName, string key, string imageViewName)
        {
            XmlDocument xml = new XmlDocument();

            using (System.IO.StreamReader sr = new System.IO.StreamReader(HttpContext.Request.InputStream))
            {
                string t = sr.ReadToEnd();
                xml.LoadXml(t);
            }

            Durados.Web.Mvc.View imageView = (Durados.Web.Mvc.View)Map.Database.Views[imageViewName];
            string fkField = imageView.Fields.Values.Where(f => f.FieldType == FieldType.Parent && ((ParentField)f).ParentView.Name.Equals(rowsViewName)).FirstOrDefault().Name;

            try
            {
                imageView.Delete(key, fkField, null, null, null);

                foreach (XmlElement element in xml.DocumentElement.ChildNodes)
                {
                    Dictionary <string, object> values = GetImageValues(imageView, key, fkField, element);

                    imageView.Create(values, null, null, null, null, null);
                }


                return(this.Content("<xml>success</xml>", "text/xml"));
            }
            catch (Exception exception)
            {
                return(this.Content(string.Format("<xml><failure>{0}</failure></xml>", exception.Message), "text/xml"));
            }
        }