Exemplo n.º 1
0
        public sealed override async Task IsActiveAsync(IsActiveContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            try
            {
                if (UserInformationProvider.IsAuthenticated() == false)
                {
                    context.IsActive = false;
                }
                else
                {
                    context.IsActive = await UserIsActiveAsync(context, UserInformationProvider.GetBitJwtToken(), OwinContext.Request.CallCancelled).ConfigureAwait(false);
                }
            }
            catch
            {
                context.IsActive = false;
            }
            finally
            {
                context.IsActive = true; // Temporary fix: To prevent redirect loop on logout.
            }

            await base.IsActiveAsync(context).ConfigureAwait(false);
        }
Exemplo n.º 2
0
        public async Task <SingleResult <UserDto> > GetCurrentUser(CancellationToken cancellationToken)
        {
            Guid userId = Guid.Parse(UserInformationProvider.GetCurrentUserId());

            return(SingleResult.Create(DtoModelMapper.FromEntityQueryToDtoQuery((await UsersRepository.GetAllAsync(cancellationToken)))
                                       .Where(u => u.Id == userId)));
        }
Exemplo n.º 3
0
        public virtual async Task <ToDoGroupDto> CreateToDoGroup(CreateToDoGroupArgs args, CancellationToken cancellationToken)
        {
            if (string.IsNullOrEmpty(args.title))
            {
                throw new BadRequestException("TitleMayNotBeEmpty");
            }

            Guid userId = Guid.Parse(UserInformationProvider.GetCurrentUserId());

            ToDoGroup addedToDoGroup = await ToDoGroupsRepository.AddAsync(new ToDoGroup
            {
                Id          = Guid.NewGuid(),
                CreatedById = userId,
                CreatedOn   = DateTimeProvider.GetCurrentUtcDateTime(),
                ModifiedOn  = DateTimeProvider.GetCurrentUtcDateTime(),
                Title       = args.title,
                Options     = new List <ToDoGroupOptions>
                {
                    new ToDoGroupOptions
                    {
                        HideCompletedToDoItems = false,
                        SortedBy = SortBy.CreatedDate,
                        Id       = Guid.NewGuid(),
                        Theme    = "Green",
                        UserId   = userId
                    }
                }
            }, cancellationToken);

            return(await GetMyToDoGroups()
                   .FirstAsync(tdg => tdg.Id == addedToDoGroup.Id, cancellationToken));
        }
Exemplo n.º 4
0
        public virtual async Task <IQueryable <UserSetting> > Get(CancellationToken cancellationToken)
        {
            string userId = UserInformationProvider.GetCurrentUserId() !;

            return((await UsersSettingsRepository
                    .GetAllAsync(cancellationToken).ConfigureAwait(false))
                   .Where(userSetting => userSetting.UserId == userId));
        }
Exemplo n.º 5
0
        public virtual async Task <IQueryable <CommentDto> > LoadComments(CancellationToken cancellationToken)
        {
            Guid customerId = Guid.Parse(UserInformationProvider.GetCurrentUserId());

            return(Mapper.FromEntityQueryToDtoQuery((await Repository
                                                     .GetAllAsync(cancellationToken))
                                                    .Where(comment => comment.CustomerId == customerId)));
        }
Exemplo n.º 6
0
        public override Task <InsurancePolicyDto> Update(Guid key, InsurancePolicyDto dto, CancellationToken cancellationToken)
        {
            Guid customerId = Guid.Parse(UserInformationProvider.GetCurrentUserId());

            dto.CustomerId = customerId;

            return(base.Update(key, dto, cancellationToken));
        }
Exemplo n.º 7
0
        public virtual async Task <IQueryable <InsurancePolicyDto> > LoadInsurancesByType(InsuranceType insuranceType, CancellationToken cancellationToken)
        {
            Guid customerId = Guid.Parse(UserInformationProvider.GetCurrentUserId());

            return(Mapper.FromEntityQueryToDtoQuery((await Repository
                                                     .GetAllAsync(cancellationToken))
                                                    .Where(insurance => insurance.CustomerId == customerId && insurance.InsuranceType == insuranceType)));
        }
Exemplo n.º 8
0
        public virtual async Task <IQueryable <SosRequestDto> > GetMySosRequests(CancellationToken cancellationToken)
        {
            Guid customerId = Guid.Parse(UserInformationProvider.GetCurrentUserId());

            return(Mapper.FromEntityQueryToDtoQuery((await Repository
                                                     .GetAllAsync(cancellationToken))
                                                    .Where(sosR => sosR.CustomerId == customerId)));
        }
Exemplo n.º 9
0
        public virtual async Task <ToDoItemDto> UpdateToDoItem(Guid key, ToDoItemDto toDoItem, CancellationToken cancellationToken)
        {
            if (toDoItem == null)
            {
                throw new BadRequestException("ToDoItemCouldNotBeNull");
            }

            Guid userId = Guid.Parse(UserInformationProvider.GetCurrentUserId());

            ToDoItem toDoItemToBeModified = await ToDoItemsRepository.GetByIdAsync(cancellationToken, key);

            if (toDoItemToBeModified == null)
            {
                throw new ResourceNotFoundException("ToDoItemCouldNotBeFound");
            }

            ToDoItemOptions toDoItemOptionsToBeModified = await ToDoItemOptionsListRepository.GetAll()
                                                          .FirstAsync(tdio => tdio.UserId == userId && tdio.ToDoItemId == key, cancellationToken);

            if (toDoItemOptionsToBeModified == null)
            {
                throw new ResourceNotFoundException("ToDoItemCouldNotBeFound");
            }

            if (toDoItem.ToDoGroupId != toDoItemToBeModified.ToDoGroupId)
            {
                throw new BadRequestException("ChangingToDoGroupIdIsNotSupportedAtTheMoment");
            }

            toDoItemToBeModified.Title       = toDoItem.Title;
            toDoItemToBeModified.IsImportant = toDoItem.IsImportant;
            toDoItemToBeModified.Notes       = toDoItem.Notes;
            toDoItemToBeModified.DueDate     = toDoItem.DueDate;

            toDoItemToBeModified.ModifiedOn = DateTimeProvider.GetCurrentUtcDateTime();

            if (toDoItemToBeModified.IsCompleted == false && toDoItem.IsCompleted == true)
            {
                toDoItemToBeModified.IsCompleted   = true;
                toDoItemToBeModified.CompletedById = userId;
            }
            else if (toDoItemToBeModified.IsCompleted == true && toDoItem.IsCompleted == false)
            {
                toDoItemToBeModified.IsCompleted   = false;
                toDoItemToBeModified.CompletedById = null;
            }

            toDoItemOptionsToBeModified.RemindOn      = toDoItem.RemindOn;
            toDoItemOptionsToBeModified.ShowInMyDayOn = toDoItem.ShowInMyDay == true ? (DateTimeOffset?)DateTimeProvider.GetCurrentUtcDateTime() : null;

            await ToDoItemsRepository.UpdateAsync(toDoItemToBeModified, cancellationToken);

            await ToDoItemOptionsListRepository.UpdateAsync(toDoItemOptionsToBeModified, cancellationToken);

            return(await GetMyToDoItems()
                   .FirstAsync(tdi => tdi.Id == key, cancellationToken));
        }
Exemplo n.º 10
0
        public override async Task <CommentDto> Create(CommentDto dto, CancellationToken cancellationToken)
        {
            Guid customerId = Guid.Parse(UserInformationProvider.GetCurrentUserId());

            dto.CustomerId = customerId;

            dto.Code = await CommentRepository.GetNextSequenceValue();

            return(await base.Create(dto, cancellationToken));
        }
Exemplo n.º 11
0
        public UserSetting GetCurrentUserSetting()
        {
            User user = UsersRepository.GetById(Guid.Parse(UserInformationProvider.GetCurrentUserId()));

            UserSetting result = new UserSetting
            {
                Culture = user.Culture.ToString()
            };

            return(result);
        }
Exemplo n.º 12
0
        public virtual async Task DeleteToDoItem(Guid key, CancellationToken cancellationToken)
        {
            Guid userId = Guid.Parse(UserInformationProvider.GetCurrentUserId());

            ToDoItem toDoItemToBeDeleted = await ToDoItemsRepository.GetByIdAsync(cancellationToken, key);

            if (toDoItemToBeDeleted == null)
            {
                throw new ResourceNotFoundException("ToDoItemCouldNotBeFound");
            }

            await ToDoItemsRepository.DeleteAsync(toDoItemToBeDeleted, cancellationToken);
        }
Exemplo n.º 13
0
        public virtual async Task <ToDoItemDto> CreateToDoItem(ToDoItemDto toDoItem, CancellationToken cancellationToken)
        {
            if (toDoItem == null)
            {
                throw new BadRequestException("ToDoItemMayNotBeNull");
            }

            Guid userId = Guid.Parse(UserInformationProvider.GetCurrentUserId());

            List <ToDoItemOptions> optionsList = new List <ToDoItemOptions> {
            };

            List <Guid> usersOfThisToDoGroup = toDoItem.ToDoGroupId == null ? (new List <Guid> {
                userId
            } /*ToDoItem has no to do group*/) : (await ToDoGroupOptionsListRepository
                                                  .GetAll()
                                                  .Where(tdgo => tdgo.ToDoGroupId == toDoItem.ToDoGroupId)
                                                  .Select(tdgo => tdgo.UserId)
                                                  .ToListAsync(cancellationToken));

            foreach (Guid otherUserId in usersOfThisToDoGroup)
            {
                ToDoItemOptions options = new ToDoItemOptions
                {
                    Id     = Guid.NewGuid(),
                    UserId = otherUserId
                };

                if (options.UserId == userId) /* For current user only */
                {
                    options.ShowInMyDayOn = toDoItem.ShowInMyDay == true ? (DateTimeOffset?)DateTimeProvider.GetCurrentUtcDateTime() : null;
                }

                optionsList.Add(options);
            }

            ToDoItem addedToDoItem = await ToDoItemsRepository.AddAsync(new ToDoItem
            {
                Id          = Guid.NewGuid(),
                CreatedById = userId,
                CreatedOn   = DateTimeProvider.GetCurrentUtcDateTime(),
                ModifiedOn  = DateTimeProvider.GetCurrentUtcDateTime(),
                Notes       = toDoItem.Notes,
                Title       = toDoItem.Title,
                ToDoGroupId = toDoItem.ToDoGroupId,
                Options     = optionsList
            }, cancellationToken);

            return(await GetMyToDoItems()
                   .FirstAsync(tdi => tdi.Id == addedToDoItem.Id, cancellationToken));
        }
Exemplo n.º 14
0
        /// <summary>
        /// Initialise une nouvelle instance de la classe <see cref="MessageDialog"/>.
        /// </summary>
        public MessageDialog()
        {
            InitializeComponent();

            try
            {
                UserInformationProvider userinfo = new UserInformationProvider();
                UsernameTB.Text = userinfo.Username;
                CompanyTB.Text  = userinfo.Company;
                EmailTB.Text    = userinfo.Email;
            }
            catch (Exception)
            {
            }
        }
Exemplo n.º 15
0
        public virtual async Task SubmitSosRequest(SubmitSosRequestArgs args, CancellationToken cancellationToken)
        {
            Guid customerId = Guid.Parse(UserInformationProvider.GetCurrentUserId());

            SosRequest req = new SosRequest
            {
                CustomerId       = customerId,
                SosRequestStatus = EvlRequestStatus.SabteAvalie,
                Latitude         = args.sosReq.Latitude,
                Longitude        = args.sosReq.Longitude,
                Description      = args.sosReq.Description
            };

            await Repository.AddAsync(req, cancellationToken);
        }
        public async Task <UserSetting> GetCurrentUserSettingAsync(CancellationToken cancellationToken)
        {
            if (UserInformationProvider.IsAuthenticated())
            {
                User user = await UsersRepository.GetByIdAsync(cancellationToken, Guid.Parse(UserInformationProvider.GetCurrentUserId()));

                UserSetting result = new UserSetting
                {
                    Culture = user.Culture.ToString()
                };

                return(result);
            }

            return(null);
        }
Exemplo n.º 17
0
        public virtual async Task KickUserFromToDoGroup(KickAnotherUserFromMyToDoGroupArge args, CancellationToken cancellationToken)
        {
            Guid userId = Guid.Parse(UserInformationProvider.GetCurrentUserId());

            ToDoGroup toDoGroupsToBeKickFrom = await ToDoGroupsRepository.GetAll()
                                               .Where(tdg => tdg.Id == args.toDoGroupId)
                                               .Select(tdg => new ToDoGroup
            {
                Id          = tdg.Id,
                CreatedById = tdg.CreatedById,
                Items       = tdg.Items.Select(tdi => new ToDoItem
                {
                    Id      = tdi.Id,
                    Options = tdi.Options.Where(tdio => tdio.UserId == args.userId).Select(tdio => new ToDoItemOptions
                    {
                        Id     = tdio.Id,
                        UserId = tdio.UserId
                    }).ToList()
                }).ToList()
            }).FirstOrDefaultAsync(cancellationToken);;

            if (toDoGroupsToBeKickFrom == null)
            {
                throw new ResourceNotFoundException("ToDoGroupCouldNotBeFound");
            }

            if (toDoGroupsToBeKickFrom.CreatedById != userId)
            {
                throw new DomainLogicException("OnlyOwnerCanKickOtherUsers");
            }

            User kickedUser = await UsersRepository.GetByIdAsync(cancellationToken, args.userId);

            if (kickedUser == null)
            {
                throw new ResourceNotFoundException("UserCouldNotBeFoundToBeKicked");
            }

            foreach (ToDoItemOptions toDoItemOptionsToBeDeleted in toDoGroupsToBeKickFrom.Items.SelectMany(tdi => tdi.Options) /* We've loaded options of to be kicked user only! */)
            {
                await ToDoItemOptionsListRepository.DeleteAsync(toDoItemOptionsToBeDeleted, cancellationToken);
            }

            ToDoGroupOptions toDoGroupOptionsToBeDeleted = await ToDoGroupOptionsListRepository.GetAll().FirstOrDefaultAsync(tdo => tdo.ToDoGroupId == args.toDoGroupId && tdo.UserId == args.userId);

            await ToDoGroupOptionsListRepository.DeleteAsync(toDoGroupOptionsToBeDeleted, cancellationToken);
        }
Exemplo n.º 18
0
 /// <summary>
 /// 개체 구하기
 /// </summary>
 /// <param name="pDataRow">데이타 로우</param>
 /// <returns>메뉴 설정 개체</returns>
 public UserInformationEntity GetEntity(DataRow pDataRow)
 {
     try
     {
         UserInformationEntity pUserInformationEntity = new UserInformationProvider(null).GetEntity(pDataRow);
         return(pUserInformationEntity);
     }
     catch (Exception pException)
     {
         throw new ExceptionManager
               (
                   this,
                   "GetEntity(pDataRow)",
                   pException
               );
     }
 }
Exemplo n.º 19
0
        public virtual async Task DeleteToDoGroup(Guid key, CancellationToken cancellationToken)
        {
            Guid userId = Guid.Parse(UserInformationProvider.GetCurrentUserId());

            ToDoGroup toDoGroupToBeDeleted = await ToDoGroupsRepository.GetByIdAsync(cancellationToken, key);

            if (toDoGroupToBeDeleted == null)
            {
                throw new ResourceNotFoundException("ToDoGroupCouldNotBeFound");
            }

            if (toDoGroupToBeDeleted.CreatedById != userId)
            {
                throw new DomainLogicException("OnlyOwnerCanDeleteTheToDoGroup");
            }

            await ToDoGroupsRepository.DeleteAsync(toDoGroupToBeDeleted, cancellationToken);
        }
Exemplo n.º 20
0
        public virtual IQueryable <ToDoGroupDto> GetMyToDoGroups()
        {
            Guid userId = Guid.Parse(UserInformationProvider.GetCurrentUserId());

            return(ToDoGroupOptionsListRepository.GetAll().Where(tdgo => tdgo.UserId == userId)
                   .Select(tdgo => new ToDoGroupDto
            {
                Id = tdgo.ToDoGroup.Id,
                CreatedBy = tdgo.ToDoGroup.CreatedBy.UserName,
                CreatedOn = tdgo.ToDoGroup.CreatedOn,
                HideCompletedToDoItems = tdgo.HideCompletedToDoItems,
                ModifiedOn = tdgo.ToDoGroup.ModifiedOn,
                SharedByCount = tdgo.ToDoGroup.Options.Count,
                SortedBy = tdgo.SortedBy,
                Theme = tdgo.Theme,
                Title = tdgo.ToDoGroup.Title
            }));
        }
Exemplo n.º 21
0
        public virtual async Task <Customer> AddNewCustomer(Customer customer, CancellationToken cancellationToken)
        {
            if (await DbContext.BlackLists.AnyAsync(bl => bl.Value == customer.FirstName || bl.Value == customer.LastName, cancellationToken))
            {
                throw new DomainLogicException("InvalidFirstNameOrLastName");
            }

            Guid currentUserId = Guid.Parse(UserInformationProvider.GetCurrentUserId());

            customer.CreatedById = currentUserId;
            customer.IsActive    = true;

            await DbContext.Customers.AddAsync(customer, cancellationToken);

            await SmsService.SendSms(customer.PhoneNo, $"Welcome {customer.FirstName} {customer.LastName}", cancellationToken);

            return(customer);
        }
Exemplo n.º 22
0
 /// <summary>
 /// 언어 정보 조회
 /// </summary>
 public DataTable User_Info_Sub(UserInformationEntity pUserInformationEntity)
 {
     try
     {
         using (DBManager pDBManager = new DBManager())
         {
             DataTable pDataTable = new UserInformationProvider(pDBManager).User_Info_Sub(pUserInformationEntity);
             return(pDataTable);
         }
     }
     catch (ExceptionManager pExceptionManager)
     {
         throw pExceptionManager;
     }
     catch (Exception pException)
     {
         throw new ExceptionManager(this, "User_Info_Sub(UserInformationEntity pUserInformationEntity)", pException);
     }
 }
Exemplo n.º 23
0
        public virtual async Task <ToDoGroupDto> ShareToDoGroupWithAnotherUser(ShareToDoGroupWithAnotherUserArgs args, CancellationToken cancellationToken)
        {
            Guid userId = Guid.Parse(UserInformationProvider.GetCurrentUserId());

            ToDoGroup toDoGroup = await ToDoGroupsRepository.GetAll()
                                  .Where(tdg => tdg.CreatedById == userId && tdg.Id == args.toDoGroupId)
                                  .Select(tdg => new ToDoGroup
            {
                Id    = tdg.Id,
                Items = tdg.Items.Select(tdi => new ToDoItem
                {
                    Id = tdi.Id
                }).ToList()
            }).FirstOrDefaultAsync(cancellationToken);

            if (toDoGroup == null)
            {
                throw new ResourceNotFoundException("ToDoGroupCouldNotBeFound");
            }

            await ToDoGroupOptionsListRepository.AddAsync(new ToDoGroupOptions
            {
                HideCompletedToDoItems = false,
                Id          = Guid.NewGuid(),
                SortedBy    = SortBy.CreatedDate,
                Theme       = "Green",
                ToDoGroupId = args.toDoGroupId,
                UserId      = args.anotherUserId
            }, cancellationToken);

            foreach (ToDoItem toDoItem in toDoGroup.Items)
            {
                await ToDoItemOptionsListRepository.AddAsync(new ToDoItemOptions
                {
                    Id            = Guid.NewGuid(),
                    ToDoItemId    = toDoItem.Id,
                    UserId        = args.anotherUserId,
                    ShowInMyDayOn = null
                }, cancellationToken);
            }

            return(await GetMyToDoGroups().FirstAsync(tdg => tdg.Id == args.toDoGroupId, cancellationToken));
        }
Exemplo n.º 24
0
 /// <summary>
 /// 언어 정보 저장
 /// </summary>
 public bool User_Image_Delete(UserInformationEntity pUserInformationEntity)
 {
     try
     {
         using (DBManager pDBManager = new DBManager())
         {
             bool isReturn = new UserInformationProvider(pDBManager).User_Image_Delete(pUserInformationEntity);
             return(isReturn);
         }
     }
     catch (ExceptionManager pExceptionManager)
     {
         throw pExceptionManager;
     }
     catch (Exception pException)
     {
         throw new ExceptionManager(this, "User_Image_Delete(UserInformationEntity pUserInformationEntity)", pException);
     }
 }
Exemplo n.º 25
0
        public virtual async Task <ToDoGroupDto> UpdateToDoGroup(Guid key, ToDoGroupDto toDoGroup, CancellationToken cancellationToken)
        {
            if (toDoGroup == null)
            {
                throw new BadRequestException("ToDoGroupMayNotBeNull");
            }

            Guid userId = Guid.Parse(UserInformationProvider.GetCurrentUserId());

            ToDoGroup toDoGroupToBeModified = await ToDoGroupsRepository.GetByIdAsync(cancellationToken, key);

            if (toDoGroupToBeModified == null)
            {
                throw new ResourceNotFoundException("ToDoGroupCouldNotBeFound");
            }

            ToDoGroupOptions toDoGroupOptionsToBeModified = await ToDoGroupOptionsListRepository.GetAll()
                                                            .FirstAsync(tdgo => tdgo.UserId == userId && tdgo.ToDoGroupId == key, cancellationToken);

            if (toDoGroupOptionsToBeModified == null)
            {
                throw new ResourceNotFoundException("ToDoGroupCouldNotBeFound");
            }

            toDoGroupToBeModified.Title      = toDoGroup.Title;
            toDoGroupToBeModified.ModifiedOn = DateTimeProvider.GetCurrentUtcDateTime();

            toDoGroupOptionsToBeModified.Theme = toDoGroup.Theme;
            toDoGroupOptionsToBeModified.HideCompletedToDoItems = toDoGroup.HideCompletedToDoItems;
            toDoGroupOptionsToBeModified.SortedBy = toDoGroup.SortedBy;

            await ToDoGroupsRepository.UpdateAsync(toDoGroupToBeModified, cancellationToken);

            await ToDoGroupOptionsListRepository.UpdateAsync(toDoGroupOptionsToBeModified, cancellationToken);

            return(await GetMyToDoGroups()
                   .FirstAsync(tdg => tdg.Id == key, cancellationToken));
        }
Exemplo n.º 26
0
        public sealed override async Task IsActiveAsync(IsActiveContext context)
        {
            try
            {
                if (UserInformationProvider.IsAuthenticated() == false)
                {
                    context.IsActive = false;
                }
                else
                {
                    context.IsActive = await UserIsActiveAsync(context, UserInformationProvider.GetCurrentUserId(), OwinContext.Request.CallCancelled).ConfigureAwait(false);
                }
            }
            catch
            {
                context.IsActive = false;
            }
            finally
            {
                context.IsActive = true; // Temporary fix: To prevent redirect loop on logout.
            }

            await base.IsActiveAsync(context).ConfigureAwait(false);
        }
Exemplo n.º 27
0
        public virtual IQueryable <ToDoItemDto> GetMyToDoItems()
        {
            Guid userId = Guid.Parse(UserInformationProvider.GetCurrentUserId());

            return(ToDoItemOptionsListRepository.GetAll().Where(tdio => tdio.UserId == userId)
                   .Select(tdio => new ToDoItemDto
            {
                Id = tdio.ToDoItem.Id,
                CreatedOn = tdio.ToDoItem.CreatedOn,
                ModifiedOn = tdio.ToDoItem.ModifiedOn,
                Title = tdio.ToDoItem.Title,
                RemindOn = tdio.RemindOn,
                CompletedBy = tdio.ToDoItem.CompletedBy.UserName,
                CreatedBy = tdio.ToDoItem.CreatedBy.UserName,
                DueDate = tdio.ToDoItem.DueDate,
                IsCompleted = tdio.ToDoItem.IsCompleted,
                IsImportant = tdio.ToDoItem.IsImportant,
                Notes = tdio.ToDoItem.Notes,
                ShowInMyDay = tdio.ShowInMyDayOn.Value.Date == DateTimeProvider.GetCurrentUtcDateTime().Date,
                ToDoGroupId = tdio.ToDoItem.ToDoGroupId,
                ToDoItemStepsCount = tdio.ToDoItem.Steps.Count(),
                ToDoItemStepsCompletedCount = tdio.ToDoItem.Steps.Count(s => s.IsCompleted == true),
            }));
        }
Exemplo n.º 28
0
        public override async Task <SingleResult <ChangeSetDto> > Create(ChangeSetDto dto, CancellationToken cancellationToken)
        {
            SingleResult <ChangeSetDto> insertedChangeSet = await base.Create(dto, cancellationToken);

            User user = await UsersRepository.GetByIdAsync(cancellationToken, Guid.Parse(UserInformationProvider.GetCurrentUserId()));

            MessageSender.SendMessageToGroups("ChangeSetHasBeenInsertedByUser", new { userName = user.UserName, title = dto.Title }, groupNames: new[] { user.Culture.ToString() });

            await BackgroundJobWorker.PerformBackgroundJobAsync <IMessageSender>(messageSender => messageSender.SendMessageToGroups("ChangeSetHasBeenInsertedByUser", new { userName = user.UserName, title = dto.Title }, new[] { user.Culture.ToString() })); // to test background job worker & message sender together!

            return(insertedChangeSet);
        }
Exemplo n.º 29
0
        public override async Task <ChangeSetDto> Create(ChangeSetDto dto, CancellationToken cancellationToken)
        {
            ChangeSetDto insertedChangeSet = await base.Create(dto, cancellationToken);

            User user = await UsersRepository.GetByIdAsync(cancellationToken, Guid.Parse(UserInformationProvider.GetCurrentUserId()));

            MessageSender.SendMessageToGroups("ChangeSetHasBeenInsertedByUser", new { userName = user.UserName, title = insertedChangeSet.Title }, groupNames: new[] { user.Culture.ToString() });

            return(insertedChangeSet);
        }
        public override async Task OnConnected(MessagesHub hub)
        {
            User user = await UsersRepository.GetByIdAsync(OwinContext.Request.CallCancelled, Guid.Parse(UserInformationProvider.GetCurrentUserId()));

            await hub.Groups.Add(hub.Context.ConnectionId, user.Culture.ToString());

            await base.OnConnected(hub);
        }