Ejemplo n.º 1
0
        public async Task <ActionResult <TicketGroup_TicketGroupDTO> > Create([FromBody] TicketGroup_TicketGroupDTO TicketGroup_TicketGroupDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

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

            TicketGroup TicketGroup = ConvertDTOToEntity(TicketGroup_TicketGroupDTO);

            TicketGroup = await TicketGroupService.Create(TicketGroup);

            TicketGroup_TicketGroupDTO = new TicketGroup_TicketGroupDTO(TicketGroup);
            if (TicketGroup.IsValidated)
            {
                return(TicketGroup_TicketGroupDTO);
            }
            else
            {
                return(BadRequest(TicketGroup_TicketGroupDTO));
            }
        }
Ejemplo n.º 2
0
        private TicketGroup ConvertDTOToEntity(TicketGroup_TicketGroupDTO TicketGroup_TicketGroupDTO)
        {
            TicketGroup TicketGroup = new TicketGroup();

            TicketGroup.Id           = TicketGroup_TicketGroupDTO.Id;
            TicketGroup.Name         = TicketGroup_TicketGroupDTO.Name;
            TicketGroup.OrderNumber  = TicketGroup_TicketGroupDTO.OrderNumber;
            TicketGroup.StatusId     = TicketGroup_TicketGroupDTO.StatusId;
            TicketGroup.TicketTypeId = TicketGroup_TicketGroupDTO.TicketTypeId;
            TicketGroup.Used         = TicketGroup_TicketGroupDTO.Used;
            TicketGroup.Status       = TicketGroup_TicketGroupDTO.Status == null ? null : new Status
            {
                Id   = TicketGroup_TicketGroupDTO.Status.Id,
                Code = TicketGroup_TicketGroupDTO.Status.Code,
                Name = TicketGroup_TicketGroupDTO.Status.Name,
            };
            TicketGroup.TicketType = TicketGroup_TicketGroupDTO.TicketType == null ? null : new TicketType
            {
                Id        = TicketGroup_TicketGroupDTO.TicketType.Id,
                Code      = TicketGroup_TicketGroupDTO.TicketType.Code,
                Name      = TicketGroup_TicketGroupDTO.TicketType.Name,
                ColorCode = TicketGroup_TicketGroupDTO.TicketType.ColorCode,
                StatusId  = TicketGroup_TicketGroupDTO.TicketType.StatusId,
                Used      = TicketGroup_TicketGroupDTO.TicketType.Used,
            };
            TicketGroup.BaseLanguage = CurrentContext.Language;
            return(TicketGroup);
        }
Ejemplo n.º 3
0
        public async Task <ActionResult <TicketGroup_TicketGroupDTO> > Get([FromBody] TicketGroup_TicketGroupDTO TicketGroup_TicketGroupDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

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

            TicketGroup TicketGroup = await TicketGroupService.Get(TicketGroup_TicketGroupDTO.Id);

            return(new TicketGroup_TicketGroupDTO(TicketGroup));
        }