コード例 #1
0
        public List <ModelViewKeyFeature> GetAllFeatureAtKey(int idKey)
        {
            var listKeyFeat = keyFeatureLogic.GetAll()
                              .Where(x => x.IdHaspKey == idKey);

            var viewFeature = new List <ModelViewKeyFeature>();

            foreach (var item in featLogic.GetAll())
            {
                model = new ModelViewKeyFeature(item)
                {
                    IdKey = idKey,
                };

                var itemKeyFeature = listKeyFeat
                                     .LastOrDefault(x => x.IdFeature == item.Id &&
                                                    x.EndDate >= date);

                if (itemKeyFeature != null)
                {
                    model.Selected     = true;
                    model.StartDate    = itemKeyFeature.StartDate;
                    model.EndDate      = itemKeyFeature.EndDate;
                    model.IdKeyFeature = itemKeyFeature.Id;
                }

                viewFeature.Add(model);
            }
            return(viewFeature);
        }
コード例 #2
0
        /// <summary>
        /// Список ключей у клиента.
        /// </summary>
        /// <param name="idClient"></param>
        /// <param name="keyFeatureClient"></param>
        private void ListKeyAtClient(int idClient, List <ModelViewKeyFeatureClient> keyFeatureClient)
        {
            if (keyFeatureClient == null)
            {
                throw new ArgumentNullException(nameof(keyFeatureClient));
            }

            var allKeyFeature        = keyFeatureLogic.GetAll();
            var listKeyFeatureClient = keyFeatureClientLogic.GetAll()
                                       .Where(x => x.IdClient == idClient);

            var listIdHaspKeyAtClient = from keyFeatCl in listKeyFeatureClient
                                        join keyActFeat in allKeyFeature
                                        on keyFeatCl.IdKeyFeature equals keyActFeat.Id
                                        select keyActFeat.IdHaspKey;

            var listKeyFeatureAtClient = from keyFeat in allKeyFeature
                                         join keyInCl in listIdHaspKeyAtClient
                                         on keyFeat.IdHaspKey equals keyInCl
                                         where keyFeat.EndDate >= date
                                         select keyFeat;

            var kyeFeature = from keyFeat in listKeyFeatureAtClient.Distinct()
                             join key in haspKeyLogic.GetAll()
                             on keyFeat.IdHaspKey equals key.Id
                             join feature in featureLogic.GetAll()
                             on keyFeat.IdFeature equals feature.Id
                             where keyFeat.EndDate >= date
                             select new ModelViewKeyFeatureClient
            {
                IdClient     = idClient,
                IdKeyFeature = keyFeat.Id,
                Feature      = feature.Name,
                NumberKey    = key.InnerId.ToString() + " - \"" + key.Number + "\"",
                EndDate      = keyFeat.EndDate,
                TypeKey      = key.TypeKey
            };

            foreach (var item in kyeFeature)
            {
                var client = listKeyFeatureClient.FirstOrDefault(x => x.IdKeyFeature == item.IdKeyFeature);
                if (client != null)
                {
                    item.Id        = client.Id;
                    item.Selected  = true;
                    item.Initiator = client.Initiator;
                    item.Note      = client.Note;
                }

                keyFeatureClient.Add(item);
            }
        }
コード例 #3
0
        public void GetAllEmptyKeyFeature()
        {
            var getAll     = new List <KeyFeature>();
            var kfExpected = new List <KeyFeature>();

            using (var db = new EntitesContext())
            {
                ClearTable.KeyFeatures(db);
                keyFeatureL = Get(db);

                getAll = keyFeatureL.GetAll();
            }
            CollectionAssert.AreEqual(getAll, kfExpected);
        }
コード例 #4
0
        public void GetAllKeyFeature()
        {
            var getAll   = new List <KeyFeature>();
            var keyFeats = CreateListEntities.KeyFeatures();

            using (var db = new EntitesContext())
            {
                ClearTable.KeyFeatures(db);
                keyFeatureL = Get(db);

                // Добавляем на прямую, чтобы избежать проверки логики.
                foreach (var kf in keyFeats)
                {
                    db.KeyFeatures.Add(kf);
                }
                db.SaveChanges();

                getAll = keyFeatureL.GetAll();
            }

            CollectionAssert.AreEqual(getAll, keyFeats);
        }