public IEnumerable <ILabel> GetAll() { using (WisTEntities context = _contextFactory.Create()) { return(context.Users.ToList().Select(x => new DatabaseLabel(x)).ToList()); } }
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); } }
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)); } }