Beispiel #1
0
 public IEnumerable <ILabel> GetAll()
 {
     using (WisTEntities context = _contextFactory.Create())
     {
         return(context.Users.ToList().Select(x => new DatabaseLabel(x)).ToList());
     }
 }
Beispiel #2
0
        public void Add(ILabel addObj)
        {
            using (WisTEntities context = _contextFactory.Create())
            {
                User user = new User(addObj);

                context.Users.Add(user);

                foreach (var image in addObj.Images)
                {
                    user.UserImages.Add(new UserImage(image));
                }

                try
                {
                    context.SaveChanges();
                }
                catch
                {
                    throw new AddExistingUserException();
                }

                addObj.Id = new Identifier(user.Id);
            }
        }
Beispiel #3
0
        public ILabel Get(IIdentifier id)
        {
            using (WisTEntities context = _contextFactory.Create())
            {
                User user = new User();

                try
                {
                    user = context.Users.Where
                               (x => x.Id == id.IdentifingCode)
                           .SingleOrDefault();
                }
                catch
                {
                    throw new LablelNotStoredException();
                }

                return(new DatabaseLabel(user));
            }
        }