Ejemplo n.º 1
0
        protected void gvOffices_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            GridViewRow row = ((GridView)sender).Rows[e.RowIndex];

            // UrlControl has limited separation of concerns and allows many variations to come out of the Url property
            // in this case, we have specified that the there has to be a file chosen from the DNN system.
            // UrlControl will use the FileID={fileid} output.  We are only interested in the actual file id.
            UrlControl urlOfficeBadge = row.FindControl("urlOfficeBadge") as UrlControl;

            if (urlOfficeBadge != null)
            {
                if (urlOfficeBadge.Url.StartsWith("FileID="))
                {
                    int fileid;
                    if (int.TryParse(urlOfficeBadge.Url.Substring(7), out fileid))
                    {
                        e.NewValues["FileId"] = fileid;
                    }
                }
                else if (urlOfficeBadge.Url.Equals(String.Empty))
                {
                    e.NewValues["FileId"] = null;
                }
            }
        }
Ejemplo n.º 2
0
        public IHttpActionResult PutUrlControl(int id, UrlControl urlControl)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != urlControl.Id)
            {
                return(BadRequest());
            }

            db.Entry(urlControl).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UrlControlExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 3
0
        public IHttpActionResult CreateUrl(string url)
        {
            bool       existUrl   = db.UrlControl.Any(w => w.Url == url);
            UrlControl urlControl = new UrlControl();

            if (!existUrl)
            {
                urlControl.Url = url;

                db.UrlControl.Add(urlControl);
                db.SaveChanges();

                var urlInfo = new
                {
                    url  = "lk" + urlControl.Id,
                    hits = 0
                };

                return(Ok(urlInfo));
            }
            else
            {
                urlControl = db.UrlControl.Where(w => w.Url == url).FirstOrDefault();
                var urlInfo = new
                {
                    url  = "lk" + urlControl.Id,
                    hits = urlControl.Hits
                };

                return(Ok(urlInfo));
            }
        }
Ejemplo n.º 4
0
        public IHttpActionResult GetUrlControl(int id)
        {
            UrlControl urlControl = db.UrlControl.Find(id);

            if (urlControl == null)
            {
                return(NotFound());
            }

            return(Ok(urlControl));
        }
Ejemplo n.º 5
0
        public IHttpActionResult PostUrlControl(UrlControl urlControl)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.UrlControl.Add(urlControl);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = urlControl.Id }, urlControl));
        }
Ejemplo n.º 6
0
        public IHttpActionResult DeleteUrlControl(int id)
        {
            UrlControl urlControl = db.UrlControl.Find(id);

            if (urlControl == null)
            {
                return(NotFound());
            }

            db.UrlControl.Remove(urlControl);
            db.SaveChanges();

            return(Ok(urlControl));
        }
Ejemplo n.º 7
0
        void InitEditControl()
        {
            if (IsNotAListOfValues)
            {
                CtlUrl    = (UrlControl)(Page.LoadControl("~/controls/URLControl.ascx"));
                CtlUrl.ID = CleanID(string.Format("{0}_url", FieldTitle));
                var container = new HtmlGenericControl("div");
                container.Attributes.Add("class", "dnnLeft");
                container.Controls.Add(CtlUrl);
                Controls.Add(container);
                ValueControl = CtlValueBox;
            }
            else
            {
                ListControl ctlListControl;
                switch (ListInputType)
                {
                case InputType.horizontalRadioButtons:
                    ctlListControl = new RadioButtonList
                    {
                        RepeatDirection = RepeatDirection.Horizontal,
                        RepeatLayout    = RepeatLayout.Flow
                    };
                    break;

                case InputType.verticalRadioButtons:
                    ctlListControl = new RadioButtonList {
                        RepeatLayout = RepeatLayout.Flow
                    };
                    break;

                default:
                    ctlListControl = new DropDownList();
                    break;
                }
                AddListItems(ctlListControl);
                CtlValueBox          = ctlListControl;
                CtlValueBox.CssClass = "NormalTextBox";
                CtlValueBox.ID       = CleanID(FieldTitle);
                ValueControl         = CtlValueBox;
                var container = new HtmlGenericControl("div");
                container.Attributes.Add("class", "dnnLeft");
                container.Controls.Add(CtlValueBox);
                Controls.Add(container);
                ValueControl = CtlValueBox;
            }
        }
Ejemplo n.º 8
0
 void EditUserLink_Init(object sender, EventArgs e)
 {
     if (IsNotAListOfValues)
     {
         CtlUrl    = (UrlControl)(Page.LoadControl("~/controls/URLControl.ascx"));
         CtlUrl.ID = CleanID(string.Format("{0}_url", FieldTitle));
         var container = new HtmlGenericControl("div");
         container.Attributes.Add("class", "dnnLeft");
         container.Controls.Add(CtlUrl);
         ValueControl = CtlUrl;
         Controls.Add(container);
     }
     else
     {
         var ctlListControl = GetListControl();
         AddListItems(ctlListControl);
         foreach (var username in InputValueList)
         {
             var user = UserController.GetUserByName(PortalId, username);
             if (user == null && Information.IsNumeric(username)) //check for valid userID:
             {
                 user = new UserController().GetUser(PortalId, int.Parse(username));
             }
             if (user != null)
             {
                 var item = new ListItem
                 {
                     Text  = NormalizeFlag ? user.Username : user.DisplayName,
                     Value = string.Format("UserId={0}", user.UserID)
                 };
                 ctlListControl.Items.Add(item);
             }
         }
         CtlValueBox          = ctlListControl;
         CtlValueBox.CssClass = "NormalTextBox";
         CtlValueBox.ID       = CleanID(FieldTitle);
         Controls.Add(CtlValueBox);
     }
 }