Esempio n. 1
0
        // GET api/<controller>
        public List<DeveloperTO> GetAllDevelopers()
        {
            List<DeveloperTO> developers = new List<DeveloperTO>();

            using (var db = new WamAppEntities1())
            {
                var devs = from d in db.Developers select d;

                foreach(Developer d in devs) {
                    DeveloperTO dev = new DeveloperTO { id = d.Id, password = d.password, username = d.username };
                    developers.Add(dev);
                }

            }

            /*
            DeveloperTO d1 = new DeveloperTO { id=123, username = "******", password = "******" };
            DeveloperTO d2 = new DeveloperTO { id=234, username = "******", password = "******" };
            DeveloperTO d3 = new DeveloperTO { id=345, username = "******", password = "******" };

            developers.Add(d1);
            developers.Add(d2);
            developers.Add(d3);
             * */

            return developers;
        }
Esempio n. 2
0
 public List<WidgetTO> GetWidgetsForPage(int pageId)
 {
     List<WidgetTO> widgetTOs = new List<WidgetTO>();
     using (var db = new WamAppEntities1())
     {
         var widgets = from w in db.Widgets
                       where w.pageId == pageId
                       select w;
         foreach (var widget in widgets)
         {
             WidgetTO widgetTO = new WidgetTO {
                 id = widget.Id,
                 name = widget.name,
                 pageId = widget.pageId.Value,
                 widgetType = widget.widgetType,
                 url = widget.url,
                 href = widget.href,
                 src = widget.src,
                 html = widget.html,
                 style = widget.style,
                 cssClass = widget.cssClass,
                 width = widget.width.Value,
                 height = widget.height.Value,
                 value = widget.value
             };
             widgetTOs.Add(widgetTO);
         }
     }
     return widgetTOs;
 }
Esempio n. 3
0
 public WidgetTO GetWidgets(int widgetId)
 {
     using (var db = new WamAppEntities1())
     {
         Widget widget = db.Widgets.Find(widgetId);
         WidgetTO wto = new WidgetTO
         {
             id = widget.Id,
             name = widget.name,
             pageId = widget.pageId.Value,
             widgetType = widget.widgetType,
             url = widget.url,
             href = widget.href,
             src = widget.src,
             html = widget.html,
             style = widget.style,
             cssClass = widget.cssClass,
             width = widget.width.Value,
             height = widget.height.Value,
             value = widget.value,
             order = widget.order.Value,
             label = widget.label,
             data = widget.data,
             content = widget.content
         };
         return wto;
     }
 }
Esempio n. 4
0
        public List<FollowingTO> GetFollowingForId(int id)
        {
            List<FollowingTO> followingTOs = new List<FollowingTO>();

            //            FollowingTO to2 = new FollowingTO { id = 234, followedId = 22, followedUsername = "******", rating = 6 };
              //          FollowingTO to3 = new FollowingTO { id = 345, followedId = 33, followedUsername = "******", rating = 7 };

            using(var db = new WamAppEntities1())
            {
                var fs = from f in db.Followings
                         where f.followerId == id
                         select f;

                foreach (var ff in fs)
                {
                    FollowingTO to = new FollowingTO
                    {
                        followedId = ff.followedId.Value,
                        followedUsername = ff.followedUsername
                    };
                    followingTOs.Add(to);
                }
            }

            //            followingTOs.Add(to2);
              //          followingTOs.Add(to3);

            return followingTOs;
        }
Esempio n. 5
0
 // 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;
 }
Esempio n. 6
0
        // GET api/<controller>/5
        public DeveloperTO GetDeveloper(int id)
        {
            DeveloperTO d4 = null;// new DeveloperTO { id = id, username = "******" + id, password = "******" };

            using (var db = new WamAppEntities1())
            {
                Developer dev = db.Developers.Find(id);
                d4 = new DeveloperTO { id = dev.Id, username = dev.username, password = dev.password };
            }

            return d4;
        }
Esempio n. 7
0
 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();
         }
     }
 }
Esempio n. 8
0
        public DeveloperTO GetDeveloperByUsername(string username)
        {
            DeveloperTO d5 = null;

            using (var db = new WamAppEntities1())
            {
                var devs = from d in db.Developers where d.username==username select d;
                Developer dd = devs.FirstOrDefault();
                if(dd != null)
                    d5 = new DeveloperTO { id = dd.Id, password = dd.password, username = dd.username };
            }

            return d5;
        }
Esempio n. 9
0
        public List<ApplicationTO> GetAllApplications()
        {
            List<ApplicationTO> applicationTOs = new List<ApplicationTO>();

            using(var db = new WamAppEntities1())
            {
                var applications = from a in db.Applications select a;
                foreach(Application app in applications){
                    ApplicationTO appTO = new ApplicationTO { id = app.Id, name = app.name };
                    applicationTOs.Add(appTO);
                }
            }

            return applicationTOs;
        }
Esempio n. 10
0
 public List<PageTO> GetPagesForApplication(int application)
 {
     List<PageTO> pageTOs = new List<PageTO>();
     using (var db = new WamAppEntities1())
     {
         var pages = from p in db.Pages
                     where p.applicationId == application
                     select p;
         foreach (var page in pages)
         {
             PageTO pageTO = new PageTO { id = page.Id, name = page.name };
             pageTOs.Add(pageTO);
         }
     }
     return pageTOs;
 }
Esempio n. 11
0
        public List<ApplicationTO> GetApplicationsForUsername(string username)
        {
            List<ApplicationTO> applicationTOs = new List<ApplicationTO>();

            using (var db = new WamAppEntities1())
            {
                var applications = from a in db.Applications
                                   join d in db.Developers
                                   on a.userId equals d.Id
                                   where d.username == username
                                   select a;
                foreach (Application app in applications)
                {
                    ApplicationTO appTO = new ApplicationTO { id = app.Id, name = app.name };
                    applicationTOs.Add(appTO);
                }
            }

            return applicationTOs;
        }
Esempio n. 12
0
        // 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();
            }
        }
Esempio n. 13
0
 // 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;
 }
Esempio n. 14
0
 // 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;
 }
Esempio n. 15
0
        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();
            }
        }