public async Task <List <StockRuleShopProdDTO> > GetListShopProdAsync(string userId) { var rules = new List <StockRuleEntity>(); using (var context = new O2OContext()) { var service = new BaseService <StockRuleEntity>(context); rules = await service .Where(x => x.UserId == userId) .Include(x => x.StockRuleShops) .Include(x => x.StockRuleProds) .ToListAsync(); } var shopProds = new List <StockRuleShopProdDTO>(); foreach (var rule in rules) { foreach (var stockRuleShop in rule.StockRuleShops) { shopProds.Add(new StockRuleShopProdDTO() { ShopNo = stockRuleShop.ShopNo, StockRuleProds = rule.StockRuleProds.Select(x => ToolsCommon.EntityToEntity(x, new StockRuleProdDTO()) as StockRuleProdDTO).ToList() }); } } return(shopProds); }
public Mt_AccountDTO GetAccount(string userId) { using (var db = new O2OContext()) { UserEntity userEntity = new BaseService <UserEntity>(db).Entities.FirstOrDefault(a => a.Id == userId); return(userEntity != null?ToolsCommon.EntityToEntity(userEntity.Mt_Accounts.FirstOrDefault(), new Mt_AccountDTO()) as Mt_AccountDTO : (Mt_AccountDTO)null); } }
public Mt_AccountDTO GetAccount(Guid id) { using (var db = new O2OContext()) { var mtAccountEntity = new BaseService <Mt_AccountEntity>(db).FirstOrDefault(a => a.Id == id); return(mtAccountEntity == null ? null : ToolsCommon.EntityToEntity(mtAccountEntity, new Mt_AccountDTO()) as Mt_AccountDTO); } }
public Ele_AccountDTO Get(Guid id) { using (var context = new O2OContext()) { var service = new BaseService <Ele_AccountEntity>(context); Ele_AccountEntity entity = service.GetById(id); return(ToolsCommon.EntityToEntity(entity, new Ele_AccountDTO()) as Ele_AccountDTO); } }
public void Update(Ele_AccountDTO dto) { using (var context = new O2OContext()) { var service = new BaseService <Ele_AccountEntity>(context); var entity = ToolsCommon.EntityToEntity(dto, new Ele_AccountEntity()) as Ele_AccountEntity; service.Update(entity); } }
public async Task <StockRuleProdDTO> GetProdAsync(Guid stockRuleId, string prodNo) { using (var context = new O2OContext()) { var service = new BaseService <StockRuleProdEntity>(context); var entity = await service.Entities.FirstOrDefaultAsync(x => x.StockRuleId == stockRuleId && x.ProdNo == prodNo); return(ToolsCommon.EntityToEntity(entity, new StockRuleProdDTO()) as StockRuleProdDTO); } }
public async Task CreateShopAsync(StockRuleShopDTO input) { using (var context = new O2OContext()) { var service = new BaseService <StockRuleShopEntity>(context); var entity = ToolsCommon.EntityToEntity(input, new StockRuleShopEntity()) as StockRuleShopEntity; service.Add(entity); } }
public UserDTO Get(string id) { using (O2OContext context = new O2OContext()) { BaseService <UserEntity> service = new BaseService <UserEntity>(context); var entity = service.Entities.FirstOrDefault(a => a.Id == id); return(ToolsCommon.EntityToEntity(entity, new UserDTO()) as UserDTO); } }
public UserDTO GetByLoginName(string loginName, string id = "") { using (O2OContext context = new O2OContext()) { BaseService <UserEntity> service = new BaseService <UserEntity>(context); var entity = service.Entities.FirstOrDefault(a => a.LoginName == loginName && (id == "" || a.Id != id)); return(ToolsCommon.EntityToEntity(entity, new UserDTO()) as UserDTO); } }
public async Task <ShopConfigDTO> GetAsync(string userId, string shopNo) { using (var context = new O2OContext()) { var service = new BaseService <ShopConfigEntity>(context); var entity = await service.Entities.FirstOrDefaultAsync(a => a.UserId == userId && a.ShopNo == shopNo); return(entity is null ? new ShopConfigDTO() : ToolsCommon.EntityToEntity(entity, new ShopConfigDTO()) as ShopConfigDTO); } }
public void Add(UserDTO dto) { using (O2OContext context = new O2OContext()) { BaseService <UserEntity> service = new BaseService <UserEntity>(context); var entity = ToolsCommon.EntityToEntity(dto, new UserEntity()) as UserEntity; service.Add(entity); } }
public void Add(List <PreProdDTO> list) { using (O2OContext context = new O2OContext()) { BaseService <PreProdEntity> service = new BaseService <PreProdEntity>(context); var entityList = list.Select(a => ToolsCommon.EntityToEntity(a, new PreProdEntity()) as PreProdEntity).ToList(); service.AddRange(entityList); } }
public void Update(Ele_ShopDTO dto) { using (O2OContext context = new O2OContext()) { BaseService <Ele_ShopEntity> service = new BaseService <Ele_ShopEntity>(context); var entity = ToolsCommon.EntityToEntity(dto, new Ele_ShopEntity()) as Ele_ShopEntity; service.Update(entity); } }
public Ele_AccountDTO Get(string userId, string shopNo) { using (var context = new O2OContext()) { var entity = from a in context.Ele_Account join b in context.Ele_Shop on a.Id equals b.AccountId where a.UserId == userId && b.ShopNo == shopNo select a; return(ToolsCommon.EntityToEntity(entity, new Ele_AccountDTO()) as Ele_AccountDTO); } }
public async Task UpdateAsync(List <ShopConfigDTO> inputs) { using (var context = new O2OContext()) { var service = new BaseService <ShopConfigEntity>(context); var userId = inputs[0].UserId; service.Delete(x => x.UserId == userId); service.AddRange(inputs.Select(x => ToolsCommon.EntityToEntity(x, new ShopConfigEntity()) as ShopConfigEntity)); } }
public List <UserDTO> GetAll(string para = "") { using (O2OContext context = new O2OContext()) { BaseService <UserEntity> service = new BaseService <UserEntity>(context); return(service.Entities. ToList(). Select(a => ToolsCommon.EntityToEntity(a, new UserDTO()) as UserDTO). ToList()); } }
public List <Mt_AccountDTO> GetList(string userId) { using (var context = new O2OContext()) { var service = new BaseService <Mt_AccountEntity>(context); return(service .Where(a => a.UserId == userId) .ToList() .Select(a => ToolsCommon.EntityToEntity(a, new Mt_AccountDTO()) as Mt_AccountDTO) .ToList()); } }
public async Task <List <ShopConfigDTO> > GetListAsync(string userId) { using (var context = new O2OContext()) { var service = new BaseService <ShopConfigEntity>(context); return((await service.Entities .Where(x => x.UserId == userId) .ToListAsync()) .Select(x => ToolsCommon.EntityToEntity(x, new ShopConfigDTO()) as ShopConfigDTO) .ToList()); } }
public async Task <List <StockRuleShopDTO> > GetListShopAsync(Guid id) { using (var context = new O2OContext()) { var service = new BaseService <StockRuleShopEntity>(context); var entities = await service.Where(x => x.StockRuleId == id).ToListAsync(); return(entities .Select(x => ToolsCommon.EntityToEntity(x, new StockRuleShopDTO()) as StockRuleShopDTO) .ToList()); } }
public List <PreProdDTO> Get(string userId) { using (O2OContext context = new O2OContext()) { BaseService <PreProdEntity> service = new BaseService <PreProdEntity>(context); var list = service .Where(a => a.UserId == userId).ToList() .Select(a => ToolsCommon.EntityToEntity(a, new PreProdDTO()) as PreProdDTO) .ToList(); return(list); } }
public List <Ele_AccountDTO> GetExpiresAccounts(DateTime dateTime) { using (O2OContext context = new O2OContext()) { var service = new BaseService <Ele_AccountEntity>(context); var list = service.Entities. Where(a => a.ExpiresDate <= dateTime). ToList(). Select(a => ToolsCommon.EntityToEntity(a, new Ele_AccountDTO()) as Ele_AccountDTO). ToList(); return(list); } }
public List <Ele_AccountDTO> GetAccounts(string userId) { using (O2OContext context = new O2OContext()) { var service = new BaseService <Ele_AccountEntity>(context); var list = service.Entities. Where(a => a.UserId == userId). ToList(). Select(a => ToolsCommon.EntityToEntity(a, new Ele_AccountDTO()) as Ele_AccountDTO). ToList(); return(list); } }
public List <Ele_ShopDTO> GetByAccountId(Guid accountId) { using (O2OContext context = new O2OContext()) { BaseService <Ele_ShopEntity> service = new BaseService <Ele_ShopEntity>(context); var list = service.Entities. Where(a => a.AccountId == accountId). ToList(). Select(a => ToolsCommon.EntityToEntity(a, new Ele_ShopDTO()) as Ele_ShopDTO). ToList(); return(list); } }
public List <Ele_ShopDTO> GetByUserId(string userId) { using (O2OContext context = new O2OContext()) { BaseService <UserEntity> service = new BaseService <UserEntity>(context); var user = service.Entities.Where(a => a.Id == userId).FirstOrDefault(); var list = new List <Ele_ShopEntity>(); foreach (var account in user.Ele_Accounts) { list.AddRange(account.Shops); } return(list.Select(a => ToolsCommon.EntityToEntity(a, new Ele_ShopDTO()) as Ele_ShopDTO).ToList()); } }
public async Task <List <StockRuleDTO> > GetListAsync(string userId) { using (var context = new O2OContext()) { var service = new BaseService <StockRuleEntity>(context); var entities = await service .Where(x => x.UserId == userId) .ToListAsync(); var dtos = entities .Select(x => ToolsCommon.EntityToEntity(x, new StockRuleDTO()) as StockRuleDTO) .ToList(); return(dtos); } }
public async Task CreateAsync(StockRuleDTO stockRule, List <StockRuleProdDTO> stockRuleProd) { var entity = ToolsCommon.EntityToEntity(stockRule, new StockRuleEntity()) as StockRuleEntity; var list = stockRuleProd.Select(x => ToolsCommon.EntityToEntity(x, new StockRuleProdEntity()) as StockRuleProdEntity).ToList(); if (entity != null) { entity.StockRuleProds = list; using (var context = new O2OContext()) { var service = new BaseService <StockRuleEntity>(context); service.Add(entity); } } }
public Ele_ShopDTO GetByShopId(long shopId) { using (O2OContext context = new O2OContext()) { BaseService <Ele_ShopEntity> service = new BaseService <Ele_ShopEntity>(context); var entity = service.Where(a => a.ShopId == shopId).FirstOrDefault(); if (entity == null) { return(null); } var dto = ToolsCommon.EntityToEntity(entity, new Ele_ShopDTO()) as Ele_ShopDTO; dto.AccessToken = entity.Account.AccessToken; dto.UserId = entity.Account.User.Id; return(dto); } }
public async Task <StockRuleShopDTO> GetShopAsync(string userId, string shopNo) { using (var context = new O2OContext()) { var service = new BaseService <StockRuleEntity>(context); var entity = await(from a in service.Entities from b in a.StockRuleShops where a.UserId == userId && b.ShopNo == shopNo select new StockRuleShopDTO() { ShopNo = b.ShopNo, ShopName = "", StockRuleId = b.StockRuleId, RuleName = a.RuleName }) .FirstOrDefaultAsync(); return(ToolsCommon.EntityToEntity(entity, new StockRuleShopDTO()) as StockRuleShopDTO); } }
public Ele_ShopDTO Get(string userId, string shopNo) { using (O2OContext context = new O2OContext()) { BaseService <Ele_ShopEntity> service = new BaseService <Ele_ShopEntity>(context); var entity = service.Entities.FirstOrDefault(a => a.Account.User.Id == userId && a.ShopNo == shopNo); if (entity != null) { var dto = ToolsCommon.EntityToEntity(entity, new Ele_ShopDTO()) as Ele_ShopDTO; dto.AccessToken = entity.Account.AccessToken; dto.UserId = userId; return(dto); } else { return(null); } } }
public async Task <List <ShopConfigDTO> > GetAutoSyncListAsync(string userId, int takeType) { using (var context = new O2OContext()) { var service = new BaseService <ShopConfigEntity>(context); if (takeType == 0) { return((await service.Entities .Where(x => x.UserId == userId && x.MtAutoSync == 1) .ToListAsync()) .Select(x => ToolsCommon.EntityToEntity(x, new ShopConfigDTO()) as ShopConfigDTO) .ToList()); } else { return((await service.Entities .Where(x => x.UserId == userId && x.EleAutoSync == 1) .ToListAsync()) .Select(x => ToolsCommon.EntityToEntity(x, new ShopConfigDTO()) as ShopConfigDTO) .ToList()); } } }