public Organization GetById(int id)
 {
     using (var con = _db.GetConnection())
     {
         Organization org  = con.Get <Organization, Address, Contact, Organization>(id);
         AccountYear  year = _yearRepository.GetById(org.ActiveYearId);
         org.Year = year;
         return(org);
     }
 }
Пример #2
0
        private static void CreateAccountYearTest()
        {
            var yearRepo = new AccountYearRepository();
            var year     = new AccountYear
            {
                //YearCode = "2020-21",
                YearBegin = new DateTime(2020, 4, 1),
                YearEnd   = new DateTime(2021, 3, 31),
                IsEnabled = true
            };

            yearRepo.Add(1, year);
        }
Пример #3
0
        public async Task UpdateAsync(Guid id, AccountYearDto model)
        {
            if (id != model.Id)
            {
                throw new ArgumentException("Year Id mismatch");
            }

            AccountYear year = _mapper.Map <AccountYear>(model);

            year.DateModified = DateTime.UtcNow;
            _context.AccountYears.Update(year);
            await _context.SaveChangesAsync();

            //return _mapper.Map<AccountYearDto>(year);
        }
Пример #4
0
        public async Task <AccountYearDto> CreateAsync(Guid orgId, AccountYearDto model)
        {
            if (orgId == null || orgId == Guid.Empty)
            {
                throw new ArgumentNullException("orgId", "Org id is missing");
            }

            AccountYear year = _mapper.Map <AccountYear>(model);

            year.OrgId        = orgId;
            year.DateCreated  = DateTime.UtcNow;
            year.DateModified = null;
            await _context.AccountYears.AddAsync(year);

            await _context.SaveChangesAsync();

            return(_mapper.Map <AccountYearDto>(year));
        }
Пример #5
0
        public async Task <bool> DeleteAsync(Guid id)
        {
            if (id == null || id == Guid.Empty)
            {
                throw new ArgumentNullException("id", "Year id is missing");
            }

            AccountYear year = await _context.AccountYears
                               .FindAsync(id);

            if (year != null)
            {
                _context.AccountYears.Remove(year);
                await _context.SaveChangesAsync();

                return(true);
            }
            throw new KeyNotFoundException("Account Year not found");
        }
Пример #6
0
        public async Task <bool> ChangeStatusAsync(ActiveStatus status)
        {
            if (status.Id == null || status.Id == Guid.Empty)
            {
                throw new ArgumentNullException("id", "Year id is missing");
            }

            AccountYear year = await _context.AccountYears
                               .FindAsync(status.Id);

            if (year != null)
            {
                year.Active = status.Active;
                _context.AccountYears.Update(year);
                await _context.SaveChangesAsync();

                return(true);
            }
            throw new KeyNotFoundException("Account year not found");
        }