Beispiel #1
0
        private OperationResult <TicketCategoryDto> CreateTicketCategory(TicketCategoryDto ticketCategory)
        {
            var domain = Mapper.Map <TicketCategory>(ticketCategory);
            var result = _repository.Create(domain);

            _repository.Save();

            return(OperationResult.Success(Mapper.Map <TicketCategoryDto>(result)));
        }
Beispiel #2
0
        public OperationResult <TicketCategoryDto> SaveCategory(TicketCategoryDto ticketCategory)
        {
            if (ticketCategory == null)
            {
                throw new ArgumentNullException(nameof(ticketCategory));
            }

            var existed = _repository.GetById <TicketCategory>(ticketCategory.Id);
            var result  = (existed != null)
                ? UpdateTicketCategory(existed, ticketCategory)
                : CreateTicketCategory(ticketCategory);

            return(result);
        }
Beispiel #3
0
        private OperationResult <TicketCategoryDto> UpdateTicketCategory(TicketCategory domain, TicketCategoryDto ticketCategory)
        {
            domain = Mapper.Map(ticketCategory, domain);
            var result = _repository.Update(domain);

            _repository.Save();

            return(OperationResult.Success(Mapper.Map <TicketCategoryDto>(result)));
        }