コード例 #1
0
        public async Task <int> EditApiaryByIdAsync(
            int apiaryId,
            string number,
            string name,
            ApiaryType apiaryType,
            string address,
            bool isRegistered,
            bool isClosed,
            DateTime?openingDate,
            DateTime?closingDate)
        {
            var apiary = this.apiaryRepository
                         .All()
                         .FirstOrDefault(a => a.Id == apiaryId);

            apiary.Number       = number;
            apiary.Name         = name;
            apiary.ApiaryType   = apiaryType;
            apiary.Adress       = address;
            apiary.IsRegistered = isRegistered;
            apiary.IsClosed     = isClosed;
            apiary.OpeningDate  = openingDate ?? DateTime.Today;
            apiary.ClosingDate  = closingDate ?? DateTime.Today;

            await this.apiaryRepository.SaveChangesAsync();

            return(apiary.Id);
        }
コード例 #2
0
        public async Task <int> CreateUserApiaryAsync(
            string userId,
            string number,
            string name,
            ApiaryType apiaryType,
            string adress,
            bool isRegistered,
            bool isClosed,
            DateTime?openingDate,
            DateTime?closingDate)
        {
            var newApiary = new Apiary
            {
                CreatorId    = userId,
                Number       = number,
                Name         = name,
                ApiaryType   = apiaryType,
                Adress       = adress,
                IsRegistered = isRegistered,
                IsClosed     = isClosed,
                OpeningDate  = openingDate ?? DateTime.Today,
                ClosingDate  = closingDate ?? DateTime.Today,
            };

            await this.apiaryRepository.AddAsync(newApiary);

            await this.apiaryRepository.SaveChangesAsync();

            await this.apiaryDiaryService.CreateAsync(newApiary.Id, string.Empty, newApiary.CreatorId);

            return(newApiary.Id);
        }