Ejemplo n.º 1
0
        public async Task UpdateAsync(Guid id, PartyCategoryDto model)
        {
            if (id != model.Id)
            {
                throw new ArgumentException("Party category id mismatch");
            }

            PartyCategory category = _mapper.Map <PartyCategory>(model);

            category.DateModified = DateTime.UtcNow;
            _context.PartyCategories.Update(category);
            await _context.SaveChangesAsync();

            //return _mapper.Map<PartyCategoryDto>(category);
        }
Ejemplo n.º 2
0
        public async Task <PartyCategoryDto> CreateAsync(Guid orgId, PartyCategoryDto model)
        {
            if (orgId == null || orgId == Guid.Empty)
            {
                throw new ArgumentNullException("orgId", "Org id is missing");
            }

            PartyCategory category = _mapper.Map <PartyCategory>(model);

            category.OrgId        = orgId;
            category.DateCreated  = DateTime.UtcNow;
            category.DateModified = null;
            await _context.PartyCategories.AddAsync(category);

            await _context.SaveChangesAsync();

            return(_mapper.Map <PartyCategoryDto>(category));
        }
Ejemplo n.º 3
0
        public async Task <bool> DeleteAsync(Guid id)
        {
            if (id == null || id == Guid.Empty)
            {
                throw new ArgumentNullException("Id", "Id is missing");
            }

            PartyCategory category = await _context.PartyCategories
                                     .FindAsync(id);

            if (category != null)
            {
                _context.PartyCategories.Remove(category);
                await _context.SaveChangesAsync();

                return(true);
            }
            throw new KeyNotFoundException("Party category not found");
        }
Ejemplo n.º 4
0
        public async Task <bool> ChangeStatusAsync(ActiveStatus status)
        {
            if (status.Id == null || status.Id == Guid.Empty)
            {
                throw new ArgumentNullException("Id", "Id is missing");
            }

            PartyCategory category = await _context.PartyCategories
                                     .FindAsync(status.Id);

            if (category != null)
            {
                category.Active = status.Active;
                _context.PartyCategories.Update(category);
                await _context.SaveChangesAsync();

                return(true);
            }
            throw new KeyNotFoundException("Party category not found");
        }
Ejemplo n.º 5
0
 public VOPartyCategory(PartyCategory instance)
 {
     this.instance = instance;
 }