示例#1
0
        public async Task <int> CreateRelationsAndSaveEvent(Event _event, DateTime date)
        {
            if (_event != null)
            {
                var year = await YearService.GetByYear(date.Year);

                if (year == null)
                {
                    year = await YearService.Save(new YearModel()
                    {
                        Year = date.Year
                    });
                }

                var month = await MonthService.GetByMonthAndYearId(date.Month, year.Id);

                if (month == null)
                {
                    month = await MonthService.Save(new MonthModel()
                    {
                        Month = date.Month, YearId = year.Id
                    });
                }

                var day = await DayService.GetByDayAndMonthId(date.Day, month.Id);

                if (day == null)
                {
                    day = await DayService.Save(new DayModel()
                    {
                        Day = date.Day, MonthId = month.Id, Date = date
                    });
                }

                _event.DayId = day.Id;
                var eventId = await EventService.Save(_event);

                return(eventId);
            }
            else
            {
                return(0);
            }
        }
示例#2
0
        public async Task SetEmojiOnDay(DateTime date, string emoji)
        {
            var year = await YearService.GetByYear(date.Year);

            if (year == null)
            {
                year = await YearService.Save(new YearModel()
                {
                    Year = date.Year
                });
            }

            var month = await MonthService.GetByMonthAndYearId(date.Month, year.Id);

            if (month == null)
            {
                month = await MonthService.Save(new MonthModel()
                {
                    Month = date.Month, YearId = year.Id
                });
            }

            var day = await DayService.GetByDayAndMonthId(date.Day, month.Id);

            if (day == null)
            {
                await DayService.Save(new DayModel()
                {
                    Day = date.Day, MonthId = month.Id, Date = date, Emoji = emoji
                });
            }
            else
            {
                await DayService.SetEmoji(emoji, day.Id);
            }
            //await DayService.SetEmoji(emoji, day.Id);
        }