Esempio n. 1
0
        public async Task <ActionResult <bool> > BulkDelete([FromBody] List <long> Ids)
        {
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            TicketIssueLevelFilter TicketIssueLevelFilter = new TicketIssueLevelFilter();

            TicketIssueLevelFilter    = TicketIssueLevelService.ToFilter(TicketIssueLevelFilter);
            TicketIssueLevelFilter.Id = new IdFilter {
                In = Ids
            };
            TicketIssueLevelFilter.Selects = TicketIssueLevelSelect.Id;
            TicketIssueLevelFilter.Skip    = 0;
            TicketIssueLevelFilter.Take    = int.MaxValue;

            List <TicketIssueLevel> TicketIssueLevels = await TicketIssueLevelService.List(TicketIssueLevelFilter);

            TicketIssueLevels = await TicketIssueLevelService.BulkDelete(TicketIssueLevels);

            if (TicketIssueLevels.Any(x => !x.IsValidated))
            {
                return(BadRequest(TicketIssueLevels.Where(x => !x.IsValidated)));
            }
            return(true);
        }
Esempio n. 2
0
        public async Task <List <Ticket_TicketIssueLevelDTO> > SingleListTicketIssueLevel([FromBody] Ticket_TicketIssueLevelFilterDTO Ticket_TicketIssueLevelFilterDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            TicketIssueLevelFilter TicketIssueLevelFilter = new TicketIssueLevelFilter();

            TicketIssueLevelFilter.Skip          = 0;
            TicketIssueLevelFilter.Take          = 20;
            TicketIssueLevelFilter.OrderBy       = TicketIssueLevelOrder.Id;
            TicketIssueLevelFilter.OrderType     = OrderType.ASC;
            TicketIssueLevelFilter.Selects       = TicketIssueLevelSelect.ALL;
            TicketIssueLevelFilter.Id            = Ticket_TicketIssueLevelFilterDTO.Id;
            TicketIssueLevelFilter.Name          = Ticket_TicketIssueLevelFilterDTO.Name;
            TicketIssueLevelFilter.OrderNumber   = Ticket_TicketIssueLevelFilterDTO.OrderNumber;
            TicketIssueLevelFilter.TicketGroupId = Ticket_TicketIssueLevelFilterDTO.TicketGroupId;
            TicketIssueLevelFilter.StatusId      = Ticket_TicketIssueLevelFilterDTO.StatusId;
            TicketIssueLevelFilter.SLA           = Ticket_TicketIssueLevelFilterDTO.SLA;

            List <TicketIssueLevel> TicketIssueLevels = await TicketIssueLevelService.List(TicketIssueLevelFilter);

            List <Ticket_TicketIssueLevelDTO> Ticket_TicketIssueLevelDTOs = TicketIssueLevels
                                                                            .Select(x => new Ticket_TicketIssueLevelDTO(x)).ToList();

            return(Ticket_TicketIssueLevelDTOs);
        }
Esempio n. 3
0
        public async Task <ActionResult <int> > Count([FromBody] TicketIssueLevel_TicketIssueLevelFilterDTO TicketIssueLevel_TicketIssueLevelFilterDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            TicketIssueLevelFilter TicketIssueLevelFilter = ConvertFilterDTOToFilterEntity(TicketIssueLevel_TicketIssueLevelFilterDTO);

            TicketIssueLevelFilter = TicketIssueLevelService.ToFilter(TicketIssueLevelFilter);
            int count = await TicketIssueLevelService.Count(TicketIssueLevelFilter);

            return(count);
        }
Esempio n. 4
0
        public async Task <ActionResult <List <TicketIssueLevel_TicketIssueLevelDTO> > > List([FromBody] TicketIssueLevel_TicketIssueLevelFilterDTO TicketIssueLevel_TicketIssueLevelFilterDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            TicketIssueLevelFilter TicketIssueLevelFilter = ConvertFilterDTOToFilterEntity(TicketIssueLevel_TicketIssueLevelFilterDTO);

            TicketIssueLevelFilter = TicketIssueLevelService.ToFilter(TicketIssueLevelFilter);
            List <TicketIssueLevel> TicketIssueLevels = await TicketIssueLevelService.List(TicketIssueLevelFilter);

            List <TicketIssueLevel_TicketIssueLevelDTO> TicketIssueLevel_TicketIssueLevelDTOs = TicketIssueLevels
                                                                                                .Select(c => new TicketIssueLevel_TicketIssueLevelDTO(c)).ToList();

            return(TicketIssueLevel_TicketIssueLevelDTOs);
        }
Esempio n. 5
0
 public TicketIssueLevelFilter ToFilter(TicketIssueLevelFilter filter)
 {
     if (filter.OrFilter == null)
     {
         filter.OrFilter = new List <TicketIssueLevelFilter>();
     }
     if (CurrentContext.Filters == null || CurrentContext.Filters.Count == 0)
     {
         return(filter);
     }
     foreach (var currentFilter in CurrentContext.Filters)
     {
         TicketIssueLevelFilter subFilter = new TicketIssueLevelFilter();
         filter.OrFilter.Add(subFilter);
         List <FilterPermissionDefinition> FilterPermissionDefinitions = currentFilter.Value;
         foreach (FilterPermissionDefinition FilterPermissionDefinition in FilterPermissionDefinitions)
         {
             if (FilterPermissionDefinition.Name == nameof(subFilter.Id))
             {
                 subFilter.Id = FilterPermissionDefinition.IdFilter;
             }
             if (FilterPermissionDefinition.Name == nameof(subFilter.Name))
             {
                 subFilter.Name = FilterPermissionDefinition.StringFilter;
             }
             if (FilterPermissionDefinition.Name == nameof(subFilter.OrderNumber))
             {
                 subFilter.OrderNumber = FilterPermissionDefinition.LongFilter;
             }
             if (FilterPermissionDefinition.Name == nameof(subFilter.TicketGroupId))
             {
                 subFilter.TicketGroupId = FilterPermissionDefinition.IdFilter;
             }
             if (FilterPermissionDefinition.Name == nameof(subFilter.StatusId))
             {
                 subFilter.StatusId = FilterPermissionDefinition.IdFilter;
             }
             if (FilterPermissionDefinition.Name == nameof(subFilter.SLA))
             {
                 subFilter.SLA = FilterPermissionDefinition.LongFilter;
             }
         }
     }
     return(filter);
 }
Esempio n. 6
0
        public async Task <bool> ValidateId(TicketIssueLevel TicketIssueLevel)
        {
            TicketIssueLevelFilter TicketIssueLevelFilter = new TicketIssueLevelFilter
            {
                Skip = 0,
                Take = 10,
                Id   = new IdFilter {
                    Equal = TicketIssueLevel.Id
                },
                Selects = TicketIssueLevelSelect.Id
            };

            int count = await UOW.TicketIssueLevelRepository.Count(TicketIssueLevelFilter);

            if (count == 0)
            {
                TicketIssueLevel.AddError(nameof(TicketIssueLevelValidator), nameof(TicketIssueLevel.Id), ErrorCode.IdNotExisted);
            }
            return(count == 1);
        }
Esempio n. 7
0
        private TicketIssueLevelFilter ConvertFilterDTOToFilterEntity(TicketIssueLevel_TicketIssueLevelFilterDTO TicketIssueLevel_TicketIssueLevelFilterDTO)
        {
            TicketIssueLevelFilter TicketIssueLevelFilter = new TicketIssueLevelFilter();

            TicketIssueLevelFilter.Selects   = TicketIssueLevelSelect.ALL;
            TicketIssueLevelFilter.Skip      = TicketIssueLevel_TicketIssueLevelFilterDTO.Skip;
            TicketIssueLevelFilter.Take      = TicketIssueLevel_TicketIssueLevelFilterDTO.Take;
            TicketIssueLevelFilter.OrderBy   = TicketIssueLevel_TicketIssueLevelFilterDTO.OrderBy;
            TicketIssueLevelFilter.OrderType = TicketIssueLevel_TicketIssueLevelFilterDTO.OrderType;

            TicketIssueLevelFilter.Id            = TicketIssueLevel_TicketIssueLevelFilterDTO.Id;
            TicketIssueLevelFilter.Name          = TicketIssueLevel_TicketIssueLevelFilterDTO.Name;
            TicketIssueLevelFilter.OrderNumber   = TicketIssueLevel_TicketIssueLevelFilterDTO.OrderNumber;
            TicketIssueLevelFilter.TicketGroupId = TicketIssueLevel_TicketIssueLevelFilterDTO.TicketGroupId;
            TicketIssueLevelFilter.TicketTypeId  = TicketIssueLevel_TicketIssueLevelFilterDTO.TicketTypeId;
            TicketIssueLevelFilter.StatusId      = TicketIssueLevel_TicketIssueLevelFilterDTO.StatusId;
            TicketIssueLevelFilter.SLA           = TicketIssueLevel_TicketIssueLevelFilterDTO.SLA;
            TicketIssueLevelFilter.CreatedAt     = TicketIssueLevel_TicketIssueLevelFilterDTO.CreatedAt;
            TicketIssueLevelFilter.UpdatedAt     = TicketIssueLevel_TicketIssueLevelFilterDTO.UpdatedAt;
            return(TicketIssueLevelFilter);
        }
Esempio n. 8
0
        private async Task <bool> HasPermission(long Id)
        {
            TicketIssueLevelFilter TicketIssueLevelFilter = new TicketIssueLevelFilter();

            TicketIssueLevelFilter = TicketIssueLevelService.ToFilter(TicketIssueLevelFilter);
            if (Id == 0)
            {
            }
            else
            {
                TicketIssueLevelFilter.Id = new IdFilter {
                    Equal = Id
                };
                int count = await TicketIssueLevelService.Count(TicketIssueLevelFilter);

                if (count == 0)
                {
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 9
0
        public async Task <List <TicketIssueLevel> > List(TicketIssueLevelFilter TicketIssueLevelFilter)
        {
            try
            {
                List <TicketIssueLevel> TicketIssueLevels = await UOW.TicketIssueLevelRepository.List(TicketIssueLevelFilter);

                return(TicketIssueLevels);
            }
            catch (Exception ex)
            {
                if (ex.InnerException == null)
                {
                    await Logging.CreateSystemLog(ex, nameof(TicketIssueLevelService));

                    throw new MessageException(ex);
                }
                else
                {
                    await Logging.CreateSystemLog(ex.InnerException, nameof(TicketIssueLevelService));

                    throw new MessageException(ex.InnerException);
                }
            }
        }
Esempio n. 10
0
        public async Task <int> Count(TicketIssueLevelFilter TicketIssueLevelFilter)
        {
            try
            {
                int result = await UOW.TicketIssueLevelRepository.Count(TicketIssueLevelFilter);

                return(result);
            }
            catch (Exception ex)
            {
                if (ex.InnerException == null)
                {
                    await Logging.CreateSystemLog(ex, nameof(TicketIssueLevelService));

                    throw new MessageException(ex);
                }
                else
                {
                    await Logging.CreateSystemLog(ex.InnerException, nameof(TicketIssueLevelService));

                    throw new MessageException(ex.InnerException);
                }
            }
        }
Esempio n. 11
0
        public async Task <TicketIssueLevel> Create(TicketIssueLevel TicketIssueLevel)
        {
            if (!await TicketIssueLevelValidator.Create(TicketIssueLevel))
            {
                return(TicketIssueLevel);
            }

            try
            {
                TicketIssueLevelFilter TicketIssueLevelFilter = new TicketIssueLevelFilter
                {
                    Take      = 1,
                    Selects   = TicketIssueLevelSelect.ALL,
                    OrderBy   = TicketIssueLevelOrder.OrderNumber,
                    OrderType = OrderType.DESC
                };

                await UOW.Begin();

                if (TicketIssueLevel.OrderNumber == 0)
                {
                    List <TicketIssueLevel> TicketIssueLevels = await UOW.TicketIssueLevelRepository.List(TicketIssueLevelFilter);

                    TicketIssueLevel.OrderNumber = TicketIssueLevels.Any() ? TicketIssueLevels.Max(c => c.OrderNumber) + 1 : 1;
                }
                // Nhắc nhở xử lý
                List <SLAAlert> SLAAlerts = new List <SLAAlert>();
                if (TicketIssueLevel.SLAAlerts != null && TicketIssueLevel.SLAAlerts.Any())
                {
                    foreach (var SLAAlert in TicketIssueLevel.SLAAlerts)
                    {
                        var newObj = SLAAlert;
                        newObj.RowId = Guid.NewGuid();
                        if (!newObj.Time.HasValue)
                        {
                            newObj.Time       = 15;
                            newObj.TimeUnitId = SLATimeUnitEnum.MINUTES.Id;
                        }
                        SLAAlerts.Add(newObj);
                    }
                }
                TicketIssueLevel.SLAAlerts = SLAAlerts;
                // Nhắc nhở phản hồi
                List <SLAAlertFRT> SLAAlertFRTs = new List <SLAAlertFRT>();
                if (TicketIssueLevel.SLAAlertFRTs != null && TicketIssueLevel.SLAAlertFRTs.Any())
                {
                    foreach (var SLAAlertFRT in TicketIssueLevel.SLAAlertFRTs)
                    {
                        var newObj = SLAAlertFRT;
                        newObj.RowId = Guid.NewGuid();
                        if (!newObj.Time.HasValue)
                        {
                            newObj.Time       = 15;
                            newObj.TimeUnitId = SLATimeUnitEnum.MINUTES.Id;
                        }
                        SLAAlertFRTs.Add(newObj);
                    }
                }
                TicketIssueLevel.SLAAlertFRTs = SLAAlertFRTs;
                // Cảnh báo xử lý
                List <SLAEscalation> SLAEscalations = new List <SLAEscalation>();
                if (TicketIssueLevel.SLAEscalations != null && TicketIssueLevel.SLAEscalations.Any())
                {
                    foreach (var SLAEscalation in TicketIssueLevel.SLAEscalations)
                    {
                        var newObj = SLAEscalation;
                        newObj.RowId = Guid.NewGuid();
                        if (!newObj.Time.HasValue)
                        {
                            newObj.Time       = 15;
                            newObj.TimeUnitId = SLATimeUnitEnum.MINUTES.Id;
                        }
                        SLAEscalations.Add(newObj);
                    }
                }
                TicketIssueLevel.SLAEscalations = SLAEscalations;
                // Cảnh báo phản hồi
                List <SLAEscalationFRT> SLAEscalationFRTs = new List <SLAEscalationFRT>();
                if (TicketIssueLevel.SLAEscalationFRTs != null && TicketIssueLevel.SLAEscalationFRTs.Any())
                {
                    foreach (var SLAEscalationFRT in TicketIssueLevel.SLAEscalationFRTs)
                    {
                        var newObj = SLAEscalationFRT;
                        newObj.RowId = Guid.NewGuid();
                        if (!newObj.Time.HasValue)
                        {
                            newObj.Time       = 15;
                            newObj.TimeUnitId = SLATimeUnitEnum.MINUTES.Id;
                        }
                        SLAEscalationFRTs.Add(newObj);
                    }
                }
                TicketIssueLevel.SLAEscalationFRTs = SLAEscalationFRTs;

                await UOW.TicketIssueLevelRepository.Create(TicketIssueLevel);

                await UOW.Commit();

                TicketIssueLevel = await UOW.TicketIssueLevelRepository.Get(TicketIssueLevel.Id);

                await Logging.CreateAuditLog(TicketIssueLevel, new { }, nameof(TicketIssueLevelService));

                return(TicketIssueLevel);
            }
            catch (Exception ex)
            {
                if (ex.InnerException == null)
                {
                    await Logging.CreateSystemLog(ex, nameof(TicketIssueLevelService));

                    throw new MessageException(ex);
                }
                else
                {
                    await Logging.CreateSystemLog(ex.InnerException, nameof(TicketIssueLevelService));

                    throw new MessageException(ex.InnerException);
                }
            }
        }