public async Task <HelpdeskTicketListModel> Handle(GetHelpdeskTicketListQuery request, CancellationToken cancellationToken) { return(new HelpdeskTicketListModel { HelpdeskTickets = await _context.Set <HelpdeskTicket>() .ProjectTo <HelpdeskTicketModel>(_mapper.ConfigurationProvider) .ToListAsync(cancellationToken) }); }
public async Task <UserRoleListModel> Handle(GetAllUserRoleQuery request, CancellationToken cancellationToken) { return(new UserRoleListModel { UserRoles = await _context.Set <UserRole>() .Where(x => x.IsDeleted == false) .ProjectTo <UserRoleModel>(_mapper.ConfigurationProvider) .ToListAsync(cancellationToken) }); }
public async Task <IssueTypeListModel> Handle( GetAllIssueTypeQuery request, CancellationToken cancellationToken) { return(new IssueTypeListModel { IssueTypes = await _context.Set <IssueType>() .ProjectTo <IssueTypeModel>(_mapper.ConfigurationProvider) .ToListAsync(cancellationToken) }); }
public async Task <StatusListModel> Handle( GetAllStatusQuery request, CancellationToken cancellationToken) { return(new StatusListModel { Statuses = await _context.Set <Status>() .Where(x => x.IsDeleted == false) .ProjectTo <StatusModel>(_mapper.ConfigurationProvider) .ToListAsync(cancellationToken) }); }
public async Task <LocationListModel> Handle( GetAllLocationQuery request, CancellationToken cancellationToken) { return(new LocationListModel { Locations = await _context.Set <Location>() .Where(x => x.IsDeleted == false) .ProjectTo <LocationModel>(_mapper.ConfigurationProvider) .ToListAsync(cancellationToken) }); }
public async Task <ConsultantMappingListModel> Handle( GetAllConsultantMappingQuery request, CancellationToken cancellationToken) { return(new ConsultantMappingListModel { ConsultantMappings = await _context.Set <ConsultantMapping>() .Where(x => x.IsDeleted == false) .ProjectTo <ConsultantMappingModel>(_mapper.ConfigurationProvider) .ToListAsync(cancellationToken) }); }
public async Task <IssueCatagoryListModel> Handle( GetAllIssueCatagoryQuery request, CancellationToken cancellationToken) { return(new IssueCatagoryListModel { IssueCatagories = await _context.Set <IssueCatagory>() .Where(x => x.IsDeleted == false) .ProjectTo <IssueCatagoryModel>(_mapper.ConfigurationProvider) .ToListAsync(cancellationToken) }); }
public async Task <UserModel> Handle(GetUserByUserNameQuery request, CancellationToken cancellationToken) { var entity = await _context.Set <User>() .Where(r => r.AdAccount.UserName == request.UserName) .ProjectTo <UserModel>(_mapper.ConfigurationProvider) .FirstOrDefaultAsync(); if (entity == null) { throw new NotFoundException(nameof(UserModel), request.UserName); } return(entity); }
public async Task <HelpdeskTicketModel> Handle(GetHelpdeskTicketByTicektNumberQuery request, CancellationToken cancellationToken) { var entity = await _context.Set <HelpdeskTicket>() .Where(r => r.TicketNumber == request.TicketNumber) .ProjectTo <HelpdeskTicketModel>(_mapper.ConfigurationProvider) .FirstOrDefaultAsync() ; if (entity == null) { throw new NotFoundException(nameof(HelpdeskTicketModel), request.TicketNumber); } return(entity); }
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 <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 <StatusModel> Handle( GetStatusByCodeQuery request, CancellationToken cancellationToken) { var entity = await _context.Set <Status>() .Where(r => r.StatusCode == request.StatusCode.ToUpper()) .ProjectTo <StatusModel>(_mapper.ConfigurationProvider) .FirstOrDefaultAsync(); if (entity == null) { throw new NotFoundException(nameof(LocationModel), request.StatusCode); } return(entity); }
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 <IssueTypeModel> Handle( GetIssueTypeByIdQuery request, CancellationToken cancellationToken) { var entity = await _context.Set <IssueType>() .Where(r => r.Id == request.Id) .ProjectTo <IssueTypeModel>(_mapper.ConfigurationProvider) .FirstOrDefaultAsync(); if (entity == null) { throw new NotFoundException(nameof(IssueTypeModel), request.Id); } return(entity); }
public async Task <LastTicket> Handle( GetLastTicketByYearCommand request, CancellationToken cancellationToken) { var entity = await _context.Set <LastTicket>() .Where(r => r.Year == DateTime.UtcNow.Year) .FirstOrDefaultAsync(); if (entity == null) { var lastTicket = await _mediator.Send(new AddLastTicketCommand()); entity = lastTicket; } return(entity); }
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(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); }
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( 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); }
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); }
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; } }