Exemplo n.º 1
0
 public Area FindArea(int id)
 {
     using (var db = new CardsDb())
     {
         return(db.Areas.FirstOrDefault(a => a.ID == id));
     }
 }
Exemplo n.º 2
0
 public Card FindCard(int id)
 {
     using (var db = new CardsDb())
     {
         return(db.Cards.FirstOrDefault(c => c.ID == id));
     }
 }
Exemplo n.º 3
0
 public List <Label> FindAllLabels()
 {
     using (var db = new CardsDb())
     {
         return(db.Labels.ToList());
     }
 }
Exemplo n.º 4
0
        public Label DeleteLabel(Label label)
        {
            using (var db = new CardsDb())
            {
                db.Entry(new Label() { ID = label.ID }).State = EntityState.Deleted;
                db.SaveChanges();

                return label;
            }
        }
Exemplo n.º 5
0
        public Label CreateLabel(Label label)
        {
            using (var db = new CardsDb())
            {
                label = db.Labels.Add(label);
                db.SaveChanges();

                return label;
            }
        }
Exemplo n.º 6
0
        public Card CreateCard(Card card)
        {
            using (var db = new CardsDb())
            {
                var result = db.Cards.Add(card);
                db.SaveChanges();

                return result;
            }
        }
Exemplo n.º 7
0
        public Area CreateArea(Area area)
        {
            using (var db = new CardsDb())
            {
                var result = db.Areas.Add(area);
                db.SaveChanges();

                return result;
            }
        }
Exemplo n.º 8
0
        public Activity CreateActivity(Activity activity)
        {
            using (var db = new CardsDb())
            {
                db.Activities.Add(activity);
                db.SaveChanges();

                return activity;
            }
        }
Exemplo n.º 9
0
        public Label CreateLabel(Label label)
        {
            using (var db = new CardsDb())
            {
                label = db.Labels.Add(label);
                db.SaveChanges();

                return(label);
            }
        }
Exemplo n.º 10
0
        public Activity CreateActivity(Activity activity)
        {
            using (var db = new CardsDb())
            {
                db.Activities.Add(activity);
                db.SaveChanges();

                return(activity);
            }
        }
Exemplo n.º 11
0
        public Card UpdateCard(Card card)
        {
            using (var db = new CardsDb())
            {
                db.Entry(card).State = EntityState.Modified;
                db.SaveChanges();

                return(card);
            }
        }
Exemplo n.º 12
0
        public Area UpdateArea(Area area)
        {
            using (var db = new CardsDb())
            {
                db.Entry(area).State = EntityState.Modified;
                db.SaveChanges();

                return(area);
            }
        }
Exemplo n.º 13
0
        public Area CreateArea(Area area)
        {
            using (var db = new CardsDb())
            {
                var result = db.Areas.Add(area);
                db.SaveChanges();

                return(result);
            }
        }
Exemplo n.º 14
0
        public Card CreateCard(Card card)
        {
            using (var db = new CardsDb())
            {
                var result = db.Cards.Add(card);
                db.SaveChanges();

                return(result);
            }
        }
Exemplo n.º 15
0
        public Label DeleteLabel(Label label)
        {
            using (var db = new CardsDb())
            {
                db.Entry(new Label()
                {
                    ID = label.ID
                }).State = EntityState.Deleted;
                db.SaveChanges();

                return(label);
            }
        }
Exemplo n.º 16
0
        public List<Area> FindAllArea()
        {
            using (var db = new CardsDb())
            {
                var areas = db.Areas.Include("Cards").Where(a => a.IsActive == true).ToList();

                //TODO find better solution
                areas.ForEach(a => a.Cards.RemoveAll(c => !c.IsActive));

                //sort
                areas.ForEach(a => a.Cards = a.Cards.OrderBy(c => c.CreatedDateUtc).ToList());

                return areas;
            }
        }
Exemplo n.º 17
0
        public List <Area> FindAllArea()
        {
            using (var db = new CardsDb())
            {
                var areas = db.Areas.Include("Cards").Where(a => a.IsActive == true).ToList();

                //TODO find better solution
                areas.ForEach(a => a.Cards.RemoveAll(c => !c.IsActive));

                //sort
                areas.ForEach(a => a.Cards = a.Cards.OrderBy(c => c.CreatedDateUtc).ToList());

                return(areas);
            }
        }
Exemplo n.º 18
0
 public Card FindCard(int id)
 {
     using (var db = new CardsDb())
     {
         return db.Cards.FirstOrDefault(c => c.ID == id);
     }
 }
Exemplo n.º 19
0
        public Card UpdateCard(Card card)
        {
            using (var db = new CardsDb())
            {
                db.Entry(card).State = EntityState.Modified;
                db.SaveChanges();

                return card;
            }
        }
Exemplo n.º 20
0
        public Area UpdateArea(Area area)
        {
            using (var db = new CardsDb())
            {
                db.Entry(area).State = EntityState.Modified;
                db.SaveChanges();

                return area;
            }
        }
Exemplo n.º 21
0
 public Area FindArea(int id)
 {
     using (var db = new CardsDb())
     {
         return db.Areas.FirstOrDefault(a => a.ID == id);
     }
 }
Exemplo n.º 22
0
 public List<Label> FindAllLabels()
 {
     using (var db = new CardsDb())
     {
         return db.Labels.ToList();
     }
 }