Пример #1
0
        public async Task <ActionResult <TicketStatus_TicketStatusDTO> > Create([FromBody] TicketStatus_TicketStatusDTO TicketStatus_TicketStatusDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            if (!await HasPermission(TicketStatus_TicketStatusDTO.Id))
            {
                return(Forbid());
            }

            TicketStatus TicketStatus = ConvertDTOToEntity(TicketStatus_TicketStatusDTO);

            TicketStatus = await TicketStatusService.Create(TicketStatus);

            TicketStatus_TicketStatusDTO = new TicketStatus_TicketStatusDTO(TicketStatus);
            if (TicketStatus.IsValidated)
            {
                return(TicketStatus_TicketStatusDTO);
            }
            else
            {
                return(BadRequest(TicketStatus_TicketStatusDTO));
            }
        }
Пример #2
0
        public async Task <ActionResult <TicketStatus_TicketStatusDTO> > Get([FromBody] TicketStatus_TicketStatusDTO TicketStatus_TicketStatusDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            if (!await HasPermission(TicketStatus_TicketStatusDTO.Id))
            {
                return(Forbid());
            }

            TicketStatus TicketStatus = await TicketStatusService.Get(TicketStatus_TicketStatusDTO.Id);

            return(new TicketStatus_TicketStatusDTO(TicketStatus));
        }
Пример #3
0
        private TicketStatus ConvertDTOToEntity(TicketStatus_TicketStatusDTO TicketStatus_TicketStatusDTO)
        {
            TicketStatus TicketStatus = new TicketStatus();

            TicketStatus.Id          = TicketStatus_TicketStatusDTO.Id;
            TicketStatus.Name        = TicketStatus_TicketStatusDTO.Name;
            TicketStatus.OrderNumber = TicketStatus_TicketStatusDTO.OrderNumber;
            TicketStatus.ColorCode   = TicketStatus_TicketStatusDTO.ColorCode;
            TicketStatus.StatusId    = TicketStatus_TicketStatusDTO.StatusId;
            TicketStatus.Used        = TicketStatus_TicketStatusDTO.Used;
            TicketStatus.Status      = TicketStatus_TicketStatusDTO.Status == null ? null : new Status
            {
                Id   = TicketStatus_TicketStatusDTO.Status.Id,
                Code = TicketStatus_TicketStatusDTO.Status.Code,
                Name = TicketStatus_TicketStatusDTO.Status.Name,
            };
            TicketStatus.BaseLanguage = CurrentContext.Language;
            return(TicketStatus);
        }