Ejemplo n.º 1
0
        public JsonResult Delete(int id)
        {
            try
            {
                DataClassesDataContext context = new Config().GetNewContext();
                var urlObj = (from u in context.Urls where u.ID == id select u).First();
                context.Urls.DeleteOnSubmit(urlObj);
                context.SubmitChanges();

                return Json(true);
            }
            catch (Exception exc)
            {
                return Json(false);
            }
        }
Ejemplo n.º 2
0
        public JsonResult Insert(FormCollection form)
        {
            try
            {
                string naam = form["naam"];
                string url = form["url"];

                int setting;
                if (!int.TryParse(form["setting"], out setting))
                    throw new ArgumentException();

                try
                {
                    if (!url.StartsWith("http://"))
                        url = "http://" + url;

                    Uri u = new Uri(url);
                    url = u.ToString();
                }
                catch
                {
                    url = "[FOUT] " + url;
                }

                DataClassesDataContext context = new Config().GetNewContext();
                Url urlObj = new Url();
                urlObj.Naam = naam;
                urlObj.Url1 = url;
                urlObj.Settings = setting;
                context.Urls.InsertOnSubmit(urlObj);
                context.SubmitChanges();

                return Json(urlObj.ID);
            }
            catch (Exception exc)
            {
                return Json(-1);
            }
        }
Ejemplo n.º 3
0
        public JsonResult Update(FormCollection form)
        {
            try
            {
                int id;
                if(!int.TryParse(form["id"], out id))
                    throw new ArgumentException();

                string naam = form["naam"];

                string url = form["url"];

                int setting;
                if(!int.TryParse(form["setting"], out setting))
                    throw new ArgumentException();

                DataClassesDataContext context = new Config().GetNewContext();
                var urlObj = (from u in context.Urls where u.ID == id select u).First();
                urlObj.Naam = naam;
                urlObj.Url1 = url;
                urlObj.Settings = setting;
                context.SubmitChanges();

                return Json(true);
            }
            catch (Exception exc)
            {
                return Json(false);
            }
        }