Exemple #1
0
 public List <int?> GetRetailerChainIdList(string userEmail)
 {
     using (var ctx = new SRLManagementEntities())
     {
         return(ctx.sp_GetRetailerChainForUser(userEmail).ToList());
     }
 }
Exemple #2
0
        public List <int> GetActorIdList(string userEmail)
        {
            List <int?> actorIdList       = new List <int?>();
            string      retailerChainList = string.Empty;
            List <int>  actorIds          = new List <int>();

            //get all the actors assigned to the user
            using (var ctx = new SRLManagementEntities())
            {
                actorIdList = ctx.sp_GetActorsForUser(userEmail).ToList();
            }

            if (actorIdList.Any())
            {
                actorIdList.ForEach(a =>
                {
                    if (a.HasValue)
                    {
                        actorIds.Add(a.Value);
                    }
                });
            }

            //get all retailer chains assigned to the user
            using (var ctx = new SRLManagementEntities())
            {
                retailerChainList = string.Join(",", ctx.sp_GetRetailerChainForUser(userEmail).ToArray());
            }

            if (!string.IsNullOrEmpty(retailerChainList))
            {
                List <Common.ActorRetailerChain> actorRetailerChainlist = new List <Common.ActorRetailerChain>();

                //get list of actors and their assigned retailer chain
                using (var ctx = new BACKUP_SRL_20180613Entities())
                {
                    actorRetailerChainlist = ctx.API_LIST_ACTORID_FOR_RETAILERCHAIN(retailerChainList).ToList()
                                             .ToEntityActorRetailerChain();
                }

                if (actorRetailerChainlist.Any())
                {
                    //remove retailer chains whose actors are assigned to the user, so as to get retailer chains for whom no actors are assigned directly to the user
                    List <Common.ActorRetailerChain> toBeRemoved =
                        actorRetailerChainlist.Where(a => actorIds.Contains(a.ActorId)).ToList();
                    if (toBeRemoved.Any())
                    {
                        List <int> toBeRemovedRetailerChain =
                            toBeRemoved.Select(a => a.RetailerChainId).Distinct().ToList();
                        toBeRemovedRetailerChain.ForEach(r =>
                        {
                            actorRetailerChainlist.RemoveAll(a => a.RetailerChainId == r);
                        });
                    }

                    actorRetailerChainlist.ForEach(a => actorIds.Add(a.ActorId));
                }
            }

            return(actorIds);
        }