Example #1
0
            public async Task <Unit> Handle(DeleteIssueTypeCommand request, CancellationToken cancellationToken)
            {
                var entity = await _context.Set <IssueType>().FindAsync(request.Id);

                if (entity == null)
                {
                    throw new NotFoundException(nameof(IssueType), request.Id);
                }

                entity.IsDeleted      = request.IsDeleted;
                entity.LastModifiedBy = request.UserModel.UserName;
                await _context.SaveChangesAsync(cancellationToken);

                return(Unit.Value);
            }
            public async Task <LastTicket> Handle(
                AddLastTicketCommand request,
                CancellationToken cancellationToken)
            {
                var entity = new LastTicket
                {
                    LastTicketNo = 0,
                    Year         = DateTime.UtcNow.Year
                };

                _context.Set <LastTicket>().Add(entity);

                await _context.SaveChangesAsync(cancellationToken);

                return(entity);
            }
            public async Task <Unit> Handle(CreateUserRoleCommand request, CancellationToken cancellationToken)
            {
                var entity = new UserRole
                {
                    CreatedBy      = "Admin",
                    LastModifiedBy = "Admin",
                    Role           = request.UserRoleModel.Role,
                    UserId         = request.UserRoleModel.UserId
                };

                _context.Set <UserRole>().Add(entity);

                await _context.SaveChangesAsync(cancellationToken);

                return(Unit.Value);
            }
            public async Task <Unit> Handle(
                CreateLocationTypeCommand request,
                CancellationToken cancellationToken)
            {
                var entity = new LocationType
                {
                    LocationTypeCode = request.LocationTypeModel.LocationTypeCode.ToUpper(),
                    Description      = request.LocationTypeModel.Description,
                    CreatedBy        = "Admin",
                    LastModifiedBy   = "Admin"
                };

                _context.Set <LocationType>().Add(entity);

                await _context.SaveChangesAsync(cancellationToken);

                return(Unit.Value);
            }
Example #5
0
            public async Task <Unit> Handle(CreateUserCommand request, CancellationToken cancellationToken)
            {
                var entity = new User
                {
                    CreatedBy      = AdAccount.For(request.UserName).UserName,
                    DepartmentName = request.DepartmentName,
                    Division       = request.Division,
                    LastModifiedBy = AdAccount.For(request.UserName).UserName,
                    Name           = new Name(request.FirstMidName, request.LastName),
                    AdAccount      = AdAccount.For(request.UserName),
                };

                _context.Set <User>().Add(entity);

                await _context.SaveChangesAsync(cancellationToken);

                return(Unit.Value);
            }
            public async Task <Unit> Handle(
                CreateIssueCatagoryCommand request,
                CancellationToken cancellationToken)
            {
                var entity = new IssueCatagory
                {
                    IssueCatagoryCode = request.IssueCatagoryModel.IssueCatagoryCode.ToUpper(),
                    Description       = request.IssueCatagoryModel.Description,
                    CreatedBy         = request.UserModel.UserName,
                    LastModifiedBy    = request.UserModel.UserName,
                };

                _context.Set <IssueCatagory>().Add(entity);

                await _context.SaveChangesAsync(cancellationToken);

                return(Unit.Value);
            }
Example #7
0
            public async Task <Unit> Handle(
                CreateStatusCommand request,
                CancellationToken cancellationToken)
            {
                var entity = new Status
                {
                    Description    = request.StatusModel.Description,
                    StatusCode     = request.StatusModel.StatusCode.ToUpper(),
                    CreatedBy      = request.UserModel.UserName,
                    LastModifiedBy = request.UserModel.UserName
                };

                _context.Set <Status>().Add(entity);

                await _context.SaveChangesAsync(cancellationToken);

                return(Unit.Value);
            }
            public async Task <Unit> Handle(UpdateLastTicketCommand request, CancellationToken cancellationToken)
            {
                var entity = await _context.Set <LastTicket>()
                             .Where(r => r.Year == DateTime.UtcNow.Year)
                             .FirstOrDefaultAsync();


                if (entity == null)
                {
                    await _mediator.Send(new AddLastTicketCommand());
                }

                entity.LastTicketNo = request.TicketNumber;

                await _context.SaveChangesAsync(cancellationToken);

                return(Unit.Value);
            }
Example #9
0
            public async Task <Unit> Handle(CreateTicketHistoryCommand request, CancellationToken cancellationToken)
            {
                var entity = new HelpdeskTicketHistory
                {
                    CreatedBy      = request.User.UserName,
                    LastModifiedBy = request.User.UserName,
                    Response       = request.TicketHistory.Response,
                    Status         = request.TicketHistory.Status,
                    TicketNumber   = request.TicketHistory.TicketNumber,
                    TicketId       = request.TicketHistory.TicketId,
                    ElapsedTime    = request.TicketHistory.ElapsedTime
                };

                _context.Set <HelpdeskTicketHistory>().Add(entity);

                await _context.SaveChangesAsync(cancellationToken);

                return(Unit.Value);
            }
            public async Task <Unit> Handle(
                CreateLocationCommand request,
                CancellationToken cancellationToken)
            {
                var entity = new Location
                {
                    CountryId      = request.LocationModel.CountryId,
                    Description    = request.LocationModel.Description,
                    LocationCode   = request.LocationModel.LocationCode.ToUpper(),
                    LocationTypeId = request.LocationModel.LocationTypeId,
                    CreatedBy      = request.UserModel.UserName,
                    LastModifiedBy = request.UserModel.UserName
                };

                _context.Set <Location>().Add(entity);

                await _context.SaveChangesAsync(cancellationToken);

                return(Unit.Value);
            }
            public async Task <Unit> Handle(
                CreateApproveMappingCommand request,
                CancellationToken cancellationToken)
            {
                var entity = new ApproverMapping
                {
                    IssueSubCatagoryId = request.ApproverMappingModel.IssueSubCatagoryId,
                    IssueTypeId        = request.ApproverMappingModel.IssueTypeId,
                    LocationId         = request.ApproverMappingModel.LocationId,
                    StatusId           = request.ApproverMappingModel.StatusId,
                    UserId             = request.ApproverMappingModel.UserId,
                    CreatedBy          = request.UserModel.UserName,
                    LastModifiedBy     = request.UserModel.UserName
                };

                _context.Set <ApproverMapping>().Add(entity);

                await _context.SaveChangesAsync(cancellationToken);

                return(Unit.Value);
            }
            private async Task <HelpdeskTicket> AddHelpdeskTicket
                (CreateNewTicketCommand request,
                CancellationToken cancellationToken)
            {
                try
                {
                    var entity = new HelpdeskTicket
                    {
                        Detail             = request.TicketModel.Desciption,
                        IssueSubCatagoryId = request.TicketModel.IssueSubCatagoryId,
                        CreatedBy          = request.UserModel.UserName,
                        LastModifiedBy     = request.UserModel.UserName,
                        IssueTypeId        = request.TicketModel.IssueTypeId,
                        LocationId         = request.TicketModel.LocationId,
                        ReportedBy         = request.UserModel.UserId,
                        PriorityLevel      = request.TicketModel.PriorityLevel,
                        StatusId           = _mediator.Send(
                            new GetStatusByCodeQuery
                        {
                            StatusCode = Constants.NewTicketStatus
                        }
                            ).Result.Id,
                        TicketNumber = GetTicketNumber(out long UpdateTicketNo)
                    };
                    _context.Set <HelpdeskTicket>().Add(entity);

                    await _context.SaveChangesAsync(cancellationToken);

                    await _mediator.Send(new UpdateLastTicketCommand
                    {
                        TicketNumber = UpdateTicketNo
                    });

                    return(entity);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }