コード例 #1
0
 public List <BreedingReminder> GetBeeRemindings(int userId)
 {
     return(_breedingRemindingRepository.Get().Where(i => i.User.Id == userId && i.BreedingType.Name == "Bee").ToList());
 }
コード例 #2
0
        public void RemindingFill(int id)
        {
            ClierRemindings(id);

            //Reminders of Field Culture.
            var fieldtypes = new List <string>
            {
                "Bread",
                "Leguminous",
                "Tuber",
                "Spicy",
                "Melon",
                "Olive",
                "Silage",
                "Fodder",
                "Fodder",
                "Forage"
            };
            var newremind = new Reminding();
            var user      = _usersRepository.Get().FirstOrDefault(i => i.Id == id);

            foreach (var profit in fieldtypes.Select(type => _growingFieldProfitsRepository.Get().Where(i => i.User.Id == id &&
                                                                                                        i.GrowingType.Name == type).ToList()).SelectMany(fieldprofits => fieldprofits.Where(profit => profit.ExpirationDate != null).
                                                                                                                                                         Where(profit => DateTime.Now > profit.ExpirationDate.Value.AddDays(-21) && profit.Remind)))
            {
                newremind.Name           = profit.Name;
                newremind.ExpirationDate = profit.ExpirationDate;
                newremind.User           = user;
                if (!IsReminding(profit.Name, profit.ExpirationDate))
                {
                    _remindingRepository.Add(newremind);
                }
            }

            //Reminders of Fruit Culture.
            var fruittypes = new List <string>
            {
                "Bergamot",
                "Kepel",
                "Finik",
                "Crataegus",
                "Tern",
                "Strawberry",
            };

            foreach (var profit in fruittypes.Select(type => _growingFruitProfitsRepository.Get().Where(i => i.User.Id == id &&
                                                                                                        i.GrowingType.Name == type).ToList()).SelectMany(fruitprofits => fruitprofits.Where(profit => profit.ExpirationDate != null).
                                                                                                                                                         Where(profit => DateTime.Now > profit.ExpirationDate.Value.AddDays(-21) && profit.Remind)))
            {
                newremind.Name           = profit.Name;
                newremind.ExpirationDate = profit.ExpirationDate;
                newremind.User           = user;
                if (!IsReminding(profit.Name, profit.ExpirationDate))
                {
                    _remindingRepository.Add(newremind);
                }
            }

            //Reminders of Breeding.
            var breendingtypes = new List <string>
            {
                "Сamel",
                "Goat",
                "Horse",
                "Pony",
                "RabbitSkin",
                "RabbitMeat",
                "Sheep",
                "HenMeat",
                "HenEgg",
                "Goose",
                "Quail",
                "Bee",
                "TeplovyeFish",
                "СoldwaterFish",
                "Swine",
                "Cattlemeat",
                "Cattlemilk",
                "Cattlemixed",
                "Pinscherdog",
                "Houndsdog",
                "Сopsdog",
                "Borzoidog"
            };

            foreach (var remind in breendingtypes.Select(type => _breedingRemindingRepository.Get().Where(i => i.User.Id == id &&
                                                                                                          i.BreedingType.Name == type).ToList()).SelectMany(breedingprofits => breedingprofits.Where(remind => remind.RemindDate != null).
                                                                                                                                                            Where(remind => DateTime.Now >= remind.RemindDate && DateTime.Now <= remind.RemindDate.Value.AddDays(Convert.ToInt32(remind.RemindDays)))))
            {
                newremind.Name           = remind.Text;
                newremind.ExpirationDate = remind.RemindDate;
                newremind.User           = user;
                if (!IsReminding(remind.Text, remind.RemindDate))
                {
                    _remindingRepository.Add(newremind);
                }
            }
        }