public Store GetById(int id) { var store = dbContext.Stores .Include(tempStore => tempStore.Menu) .FirstOrDefault(a => a.Id == id); return(mapper.MapData <Store, StoreDO>(store)); }
public User GetByName(string name) { var userWithId = dbContext.Users.SingleOrDefault(user => user.Name == name); if (userWithId == null) { throw new UserNotFoundException("User not found"); } return(mapper.MapData <User, UserDO>(userWithId)); }
public void Create(Session sessionToCreate) { if (sessionToCreate == null) { throw new SessionNotFoundException(); } else if (sessionToCreate.Stores.Count().Equals(0)) { throw new SessionIsEmptyException(); } else { var sessionDO = mapper.MapData <SessionDO, Session>(sessionToCreate); sessionDO.IsActive = true; dbContext.Add(sessionDO); dbContext.SaveChanges(); } }