コード例 #1
0
ファイル: DevelopersController.cs プロジェクト: jannunzi/dev
 // DELETE api/<controller>/5
 public int DeleteDeveloper(int id)
 {
     using (var db = new WamAppEntities1())
     {
         Developer dev = db.Developers.Find(id);
         db.Developers.Remove(dev);
         db.SaveChanges();
     }
     return id;
 }
コード例 #2
0
ファイル: WidgetsController.cs プロジェクト: jannunzi/dev
 public void DeleteWidgets(int id)
 {
     using (var db = new WamAppEntities1())
     {
         Widget widget = db.Widgets.Find(id);
         if(widget != null)
         {
             db.Widgets.Remove(widget);
             db.SaveChanges();
         }
     }
 }
コード例 #3
0
ファイル: WidgetsController.cs プロジェクト: jannunzi/dev
        // actually this is not a get, should be a post.
        // creates new widget for pageId
        public void GetWidgetForPage(int pageId, string widgetType, int order)
        {
            widgetType = widgetType.ToUpper();
            using(var db = new WamAppEntities1())
            {
                Widget widget = new Widget();
                widget.name = "Widget Name";
                widget.pageId = pageId;
                widget.widgetType = widgetType;
                widget.height = 0;
                widget.width = 0;
                widget.src = "";
                widget.order = order;
                widget.href = "";
                widget.html = "";
                widget.value = "";
                widget.style = "";
                widget.cssClass = "";

                db.Widgets.Add(widget);
                db.SaveChanges();
            }
        }
コード例 #4
0
ファイル: DevelopersController.cs プロジェクト: jannunzi/dev
 // PUT api/<controller>/5
 public string PutDeveloper(int id, DeveloperTO developer)
 {
     using (var db = new WamAppEntities1())
     {
         Developer dev = db.Developers.Find(id);
         dev.password = developer.password;
         db.SaveChanges();
     }
     return developer.username + " " + id;
 }
コード例 #5
0
ファイル: DevelopersController.cs プロジェクト: jannunzi/dev
 // POST api/<controller>
 public string PostDeveloper(DeveloperTO developer)
 {
     using(var db = new WamAppEntities1())
     {
         Developer newDeveloper = new Developer();
         newDeveloper.username = developer.username;
         newDeveloper.password = developer.password;
         db.Developers.Add(newDeveloper);
         db.SaveChanges();
     }
     return developer.username;
 }
コード例 #6
0
ファイル: WidgetsController.cs プロジェクト: jannunzi/dev
        public void PutWidgets(WidgetTO widgetTO)
        {
            using (var db = new WamAppEntities1())
            {
                Widget widget = db.Widgets.Find(widgetTO.id);
                widget.name = widgetTO.name;
                widget.width = widgetTO.width;
                widget.height = widgetTO.height;
                widget.order = widgetTO.order;
                widget.label = widgetTO.label;
                widget.html = widgetTO.html;
                widget.value = widgetTO.value;
                widget.style = widgetTO.style;
                widget.content = widgetTO.content;
                widget.data = widgetTO.data;

                if (widgetTO.order != widget.order.Value)
                {
                    int min = Math.Min(widget.order.Value, widgetTO.order);
                    int max = Math.Max(widget.order.Value, widgetTO.order);
                    var widgets = from w in db.Widgets
                                  where w.order >= min
                                  && w.order <= max
                                  select w;
                    if (widgetTO.order > widget.order.Value)
                    {
                        foreach (var wid in widgets)
                        {
                            wid.order--;
                        }
                    }
                    else
                    {
                        foreach (var wid in widgets)
                        {
                            wid.order++;
                        }
                    }
                    widget.order = widgetTO.order;
                }

                db.SaveChanges();
            }
        }