private void DataSynchEntity(object entity, string oper) { if (entity == null) { return; } RealtimeData data = new RealtimeData(); data.Oper = oper; data.Type = "position"; if (entity is OrgPosition) { OrgPosition position = entity as OrgPosition; List <OrgPosition> positions = new List <OrgPosition>(); positions.Add(position); data.Data = positions; } else if (entity is List <OrgPosition> ) { List <OrgPosition> positions = entity as List <OrgPosition>; data.Data = positions; } this._eventBus.PublishAsync(new RealtimeSynEvent(data)); //RealtimeSynchServiceFactory.GetInstance().EnqueueQueue(data); }
public async Task <List <SearchedOrgPositionModel> > Handle(SaveOrgPositionCommand request, CancellationToken cancellationToken) { List <SearchedOrgPositionModel> result = new List <SearchedOrgPositionModel>(); if (request.Id == null || request.Id == default(int)) { result = await _mediator.Send(new SearchOrgPosition_Query() { PositionTypeId = request.PositionTypeId, OrgUnitTypeId = request.OrgUnitTypeId }); if (result.Any()) { throw new BusinessRulesException("وظیفه انتخاب شده از قبل در سیستم موجود است"); } using (_context) { OrgPosition orgposition = new OrgPosition() { ParentId = request.ParentId, PositionTypeId = request.PositionTypeId, OrgUnitTypeId = request.OrgUnitTypeId, RankId = request.RankId, }; _context.OrgPosition.Add(orgposition); await _context.SaveChangesAsync(cancellationToken); result = await _mediator.Send(new SearchOrgPosition_Query() { Id = orgposition.Id }); } } else { using (_context) { OrgPosition toUpdateRecord = await _context.OrgPosition.Where(or => or.Id == request.Id).SingleOrDefaultAsync(); toUpdateRecord.ParentId = request.ParentId; toUpdateRecord.PositionTypeId = request.PositionTypeId; toUpdateRecord.OrgUnitTypeId = request.OrgUnitTypeId; toUpdateRecord.RankId = request.RankId; await _context.SaveChangesAsync(cancellationToken); result = await _mediator.Send(new SearchOrgPosition_Query() { Id = toUpdateRecord.Id }); } } return(result); }
public int IndexOf(OrgPosition entity) { return base.IndexOf(entity); }
public bool Contains(OrgPosition entity) { return base.Contains(entity); }
public void Add(OrgPosition entity) { base.Add(entity); }
public bool Remove(OrgPosition entity) { return base.Remove(entity); }
public void Insert(int index, OrgPosition entity) { base.Insert(index, entity); }