Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 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);
     }
 }
Exemplo n.º 3
0
 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);
     }
 }
Exemplo n.º 4
0
        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);
            }
        }
Exemplo n.º 5
0
        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);
            }
        }
Exemplo n.º 6
0
        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);
            }
        }
Exemplo n.º 7
0
        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);
            }
        }
Exemplo n.º 8
0
        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);
            }
        }
Exemplo n.º 9
0
        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);
            }
        }
Exemplo n.º 10
0
        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);
            }
        }
Exemplo n.º 11
0
        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);
            }
        }
Exemplo n.º 12
0
        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);
            }
        }
Exemplo n.º 13
0
        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);
            }
        }
Exemplo n.º 14
0
        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);
            }
        }
Exemplo n.º 15
0
        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));
            }
        }
Exemplo n.º 16
0
        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());
            }
        }
Exemplo n.º 17
0
        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());
            }
        }
Exemplo n.º 18
0
        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());
            }
        }
Exemplo n.º 19
0
        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());
            }
        }
Exemplo n.º 20
0
        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);
            }
        }
Exemplo n.º 21
0
        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);
            }
        }
Exemplo n.º 22
0
        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);
            }
        }
Exemplo n.º 23
0
        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);
            }
        }
Exemplo n.º 24
0
        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());
            }
        }
Exemplo n.º 25
0
        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);
            }
        }
Exemplo n.º 26
0
        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);
                }
            }
        }
Exemplo n.º 27
0
        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);
            }
        }
Exemplo n.º 28
0
        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);
            }
        }
Exemplo n.º 29
0
        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);
                }
            }
        }
Exemplo n.º 30
0
        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());
                }
            }
        }