/// <summary> /// Инициализировать приглашение /// </summary> internal void Initialize( Guid id, Guid alienId, Guid employeeId, Guid visitDetailId, ICollection <ForeignParticipant> foreignParticipants, DateTimeOffset createdDate, DateTimeOffset updateDate, InvitationStatus invitationStatus) { /*Contract.Argument.IsValidIf(Id != id, $"{Id} (current) != {id} (new)"); * Contract.Argument.IsNotEmptyGuid(id, nameof(id)); * Contract.Argument.IsValidIf(createdDate <= updateDate, $"{nameof(createdDate)}:{createdDate} < {nameof(updateDate)}:{updateDate}"); * Contract.Argument.IsNotEmptyGuid(alienId, nameof(alienId)); * Contract.Argument.IsNotEmptyGuid(employeeId, nameof(employeeId)); * Contract.Argument.IsNotEmptyGuid(visitDetailId, nameof(visitDetailId));*/ Id = id; SetAlienId(alienId); SetEmployeeId(employeeId); SetVisitDetailId(visitDetailId); SetForeignParticipants(foreignParticipants); SetCreatedDate(createdDate); SetUpdateDate(updateDate); SetInvitationStatus(invitationStatus); }
public Invitation(string id, Team team, Role role, InvitationStatus status) { Id = id; Team = team; Role = role; Status = status; }
public void Respond(InvitationStatus status) { var statusData = new Dictionary <string, string> { { "status", status.ToString() } }; HttpContent content = new FormUrlEncodedContent(statusData); try { HttpResponseMessage response = httpc.PutAsync(String.Format("api/groups/{0}/invitations/{1}", groupId, user.Id), content).Result; if (response.IsSuccessStatusCode) { return; } throw new Exception(); } catch { return; } }
public ActionResult <string> UpdateInvitation(int groupId, int userId, [FromForm] InvitationStatus status) { if (!this.groupService.Exists(groupId)) { return(BadRequest(new { message = "Invalid group id" })); } if (!this.userService.Exists(userId)) { return(BadRequest(new { message = "Invalid user id" })); } try { Invitation invitation = this.groupService.UpdateInvitation(userId, groupId, status); if (status == InvitationStatus.Accepted) { this.groupService.AddUserToGroup(userId, groupId, invitation.IsAdmin); } return(Ok(new { message = "Invitation updated" })); } catch { return(BadRequest(new { message = "Could not add user " + userId + " to group " + groupId })); } }
public async Task <ActionResult <Invitation> > SetStatus([FromRoute] string id, [FromBody] InvitationUpdate invitationUpdate) { InvitationStatus invitationStatus = invitationUpdate.InvitationStatus; UserModel user = await userManager.GetUserAsync(HttpContext.User); Invitation invitation = await invitationService.GetById(id); if (invitation == null) { return(Status404NotFound("Invitation")); } if (!invitation.Involves(user.UserId)) { return(Status403Forbidden()); } return(invitation.InvitationType switch { InvitationType.SessionInvite => await UpdateSessionInviteStatus( user, invitation, invitationStatus ), InvitationType.FriendRequest => await UpdateFriendRequestStatus( user, invitation, invitationStatus ), _ => throw new ArgumentOutOfRangeException() });
/// <summary> /// Инициализировать логи приглашения /// </summary> public void Initialize( Guid id, Guid alienId, Guid employeeId, Guid visitDetailId, DateTime createdDate, DateTime updateDate, InvitationStatus status, long revisionNumber) { Contract.Argument.IsNotEmptyGuid(id, nameof(id)); Contract.Argument.IsNotEmptyGuid(alienId, nameof(alienId)); Contract.Argument.IsNotEmptyGuid(employeeId, nameof(employeeId)); Contract.Argument.IsNotEmptyGuid(visitDetailId, nameof(visitDetailId)); Contract.Argument.IsValidIf(revisionNumber > 0, $"{nameof(revisionNumber)} > 0"); Contract.Argument.IsValidIf(createdDate <= updateDate, $"{nameof(createdDate)}:{createdDate} < {nameof(updateDate)}:{updateDate}"); Id = id; AlienId = alienId; EmployeeId = employeeId; VisitDetailId = visitDetailId; CreatedDate = createdDate; UpdateDate = updateDate; Status = status; }
/// <summary> /// Создать приглашение /// </summary> /// <param name="alienId">Иностранец</param> /// <param name="employeeId">Сотрудник</param> /// <param name="visitDetailId">Детали визита</param> /// <param name="foreignParticipants">Сопровождение</param> /// <param name="createdDate">Дата создания</param> /// <param name="updateDate">Дата изменения</param> /// <param name="invitationStatus">Статус приглашения</param> /// <returns>Идентификатор приглашения</returns> public Invitation Create( Guid alienId, Guid employeeId, Guid visitDetailId, ICollection <ForeignParticipant> foreignParticipants, DateTimeOffset createdDate, DateTimeOffset updateDate, InvitationStatus invitationStatus) { Contract.Argument.IsNotEmptyGuid(alienId, nameof(alienId)); Contract.Argument.IsNotEmptyGuid(employeeId, nameof(employeeId)); Contract.Argument.IsNotEmptyGuid(visitDetailId, nameof(visitDetailId)); Contract.Argument.IsNotNull(foreignParticipants, nameof(foreignParticipants)); Contract.Argument.IsValidIf(createdDate <= updateDate, $"{nameof(createdDate)}:{createdDate} < {nameof(updateDate)}:{updateDate}"); var createdInvitation = _context.Set <Invitation>().Create(); var id = _idGenerator.Generate(); createdInvitation.Initialize( id: id, alienId: alienId, employeeId: employeeId, visitDetailId: visitDetailId, foreignParticipants: foreignParticipants, createdDate: createdDate, updateDate: updateDate, invitationStatus: invitationStatus); var newInvitation = _context.Set <Invitation>().Add(createdInvitation); return(newInvitation); }
/// <summary> /// Создать лог приглашения /// </summary> /// <param name="alienId">Идентификатор иностранца</param> /// <param name="employeeId">Идентификатор сотрудника</param> /// <param name="visitDetailId">Идентификатор деталей визита</param> /// <param name="createdDate">Дата создания</param> /// <param name="updateDate">Дата изменения</param> /// <param name="invitationStatus">Статус приглашения</param> /// <param name="revisionNumber">Номер ревизии</param> /// <returns>Идентификатор лога приглашения</returns> public Guid Create( Guid alienId, Guid employeeId, Guid visitDetailId, DateTime createdDate, DateTime updateDate, InvitationStatus invitationStatus, long revisionNumber) { Contract.Argument.IsNotEmptyGuid(alienId, nameof(alienId)); Contract.Argument.IsNotEmptyGuid(employeeId, nameof(employeeId)); Contract.Argument.IsNotEmptyGuid(visitDetailId, nameof(visitDetailId)); Contract.Argument.IsValidIf(createdDate <= updateDate, $"{nameof(createdDate)}:{createdDate} < {nameof(updateDate)}:{updateDate}"); Contract.Argument.IsValidIf(revisionNumber > 0, $"{nameof(revisionNumber)} > 0"); var createdInvitationLog = _context.Set <InvitationLog>().Create(); var id = _idGenerator.Generate(); createdInvitationLog.Initialize( id: id, alienId: alienId, employeeId: employeeId, visitDetailId: visitDetailId, createdDate: createdDate, updateDate: updateDate, status: invitationStatus, revisionNumber: revisionNumber); var newInvitationLog = _context.Set <InvitationLog>().Add(createdInvitationLog); return(newInvitationLog.Id); }
public EmployerAccountTeamRepositoryTestFixtures WithInvitation( InvitationStatus status, DateTime expiryDate, string email, out string hashedId) { using (var db = CreateDbContext()) { var account = CreateAccount(db); hashedId = account.HashedId; db.SaveChanges(); var invitation = new Invitation { AccountId = account.Id, Status = status, ExpiryDate = expiryDate, Email = email }; CheckInvitationRepository(repo => repo.Create(invitation)); } return(this); }
public Invitation(string id, string teamId, Role role, InvitationStatus status, string emailAddress) { Id = id; TeamId = teamId; Role = role; Status = status; EmailAddress = emailAddress; }
public void RespondInvitation(Invitation invitation, InvitationStatus invitationStatus) { if (invitation != null) { invitation.Status = invitationStatus; _dbContext.Invitations.Update(invitation); } }
// TODO: atrybut realizujący związek z klasą InvitationStatus public Invitation(Contact contact) { ContactId = contact.Id; FirstName = contact.FirstName; Surname = contact.Surname; Email = contact.Email; invitationStatus = InvitationStatus.CREATED; }
public Invitation(string id, InvitationRequest request) { this.Id = id; this.From = request.From; this.To = request.To; this.EventId = request.EventId; this.Status = request.Status; }
private Invitation(InvitationId id, PersonId senderId, PersonId receiverId, DateTimeOffset createdAt, InvitationStatus status) : base(id) { SenderId = senderId; ReceiverId = receiverId; CreatedAt = createdAt; Status = status; Apply(new FriendshipInvitationCreatedDomainEvent(id, senderId, receiverId, createdAt)); }
public async Task <InvitationStatus> Update(int id, [FromBody] InvitationStatusModel invitationStatusmodel) { InvitationStatus invitationStatus = await _context.InvitationStatuses.FindAsync(id); invitationStatus.Update(invitationStatusmodel.Name); await _context.SaveChangesAsync(); return(invitationStatus); }
public async Task <InvitationStatus> Delete(int id) { InvitationStatus invitationStatus = await _context.InvitationStatuses.FindAsync(id); invitationStatus.DeActive(); await _context.SaveChangesAsync(); return(invitationStatus); }
public void ChangeStatus(int invitationId, InvitationStatus newStatus) { var invitation = context.Invitations.Find(invitationId); context.Entry(invitation).State = Microsoft.EntityFrameworkCore.EntityState.Unchanged; invitation.Status = newStatus; context.Entry(invitation).Property(i => i.Status).IsModified = true; context.SaveChanges(); }
public async Task UpdateClientStatus(string recruiterId, string clientId, InvitationStatus status) { var recruiter = await _recruitorRepository.GetByIdAsync(recruiterId); recruiter.Clients.FirstOrDefault(x => x.EmployerId == clientId) .InvitationStatus = status; await _recruitorRepository.Update(recruiter); }
/// <summary> /// Задать статус приглашения /// </summary> /// <param name="invitationStatus">Статус приглашения</param> public void SetInvitationStatus(InvitationStatus invitationStatus) { if (Status == invitationStatus) { return; } Status = invitationStatus; }
/// <summary> /// Задать статус приглашения /// </summary> /// <param name="invitationStatus">Статус приглашения</param> internal void SetInvitationStatus(InvitationStatus invitationStatus) { if (Status == invitationStatus) { return; } Status = invitationStatus; }
public InvitationDto(int id, InvitationStatus status, int groupId, int fromUser, int toUser, MemberRole suggestedRole) { Id = id; Status = status; GroupId = groupId; FromUser = fromUser; ToUser = toUser; SuggestedRole = suggestedRole; }
public void Should_Construct_InvitationStatus() { InvitationStatus invitationStatus = new InvitationStatus(); _ = invitationStatus.InvitationStatusId; _ = invitationStatus.NameAr; _ = invitationStatus.NameEn; invitationStatus.ShouldNotBeNull(); }
public async Task <InvitationStatus> Create([FromBody] InvitationStatusModel invitationStatusmodel) { Check.ArgumentNotNull(nameof(invitationStatusmodel), invitationStatusmodel); InvitationStatus invitationStatus = new InvitationStatus(invitationStatusmodel.Name); _context.InvitationStatuses.Add(invitationStatus); await _context.SaveChangesAsync(); return(invitationStatus); }
public void AddUserToMeeting(string userId, int meetingId, InvitationStatus status) { _applicationDbContext.MeetingInvitedUser.Add(new MeetingInvitedUser { MeetingId = meetingId, UserId = userId, Status = status }); _applicationDbContext.SaveChanges(); }
public ChatViewModel(ServerConnection connection, Navigator navigator, string username, byte[] userKey) : base(connection, navigator) { this.model = new ChatModel(connection, username, userKey); this.lastInvitationStatus = InvitationStatus.NO_INVITATION; this.lastRecivedInvitation = null; this.selectedFriend = null; this.invitationUsername = ""; this.messageToSendText = ""; this.activeConversation = false; updateThread = new Thread(UpdateAsync); updateThread.Start(); }
private bool IsWrongStatusToDelete(InvitationStatus status) { switch (status) { case InvitationStatus.Pending: case InvitationStatus.Expired: return(false); default: return(true); } }
public void ChangeInvitationStatus(Guid teamId, Guid userId, InvitationStatus invitationStatus, string quote) { TeamMember member = repository.GetMembership(teamId, userId); if (member != null) { member.InvitationStatus = invitationStatus; member.Quote = quote; } repository.UpdateMembership(teamId, member); }
public static async Task <HttpResponseMessage> RespondInvitation( string email, int invitationId, InvitationStatus invitationStatus) { var jsonObject = JsonConvert.SerializeObject(new { invitationStatus = invitationStatus }); var content = new StringContent(jsonObject.ToString(), Encoding.UTF8, "application/json"); return(await _httpClient.PostAsync( string.Format(ApiConstants.RespondInvitationEndpoint, email, invitationId), content)); }
/// <summary> /// 生成请求内容 /// </summary> /// <param name="Invitation">请求实体</param> /// <param name="status">请求状态</param> /// <returns>返回生成的请求内容</returns> public string Resolve(dynamic Invitation, InvitationStatus status) { if (Invitation == null) { return(string.Empty); } if (!InvitationTemplates.ContainsKey(Invitation.InvitationTypeKey)) { throw new ExceptionFacade(new ResourceExceptionDescriptor().WithContentNotFound("请求模板", Invitation.InvitationTypeKey)); } InvitationTemplate invitationTemplate = InvitationTemplates[Invitation.InvitationTypeKey]; if (invitationTemplate == null) { return(string.Empty); } string razorTemplate = string.Empty; switch (status) { case InvitationStatus.Unhandled: razorTemplate = invitationTemplate.UnhandledBody; break; case InvitationStatus.Accept: razorTemplate = invitationTemplate.AcceptBody; break; case InvitationStatus.Refuse: razorTemplate = invitationTemplate.RefuseBody; break; default: razorTemplate = invitationTemplate.UnhandledBody; break; } if (string.IsNullOrEmpty(razorTemplate)) { return(string.Empty); } //使用RazorEngine解析请求内容 try { return(Razor.Parse(razorTemplate, Invitation, Invitation.InvitationTypeKey)); } catch (Exception e) { throw new ExceptionFacade(new CommonExceptionDescriptor("编译请求模板时报错"), e); } }
private void SendInvitationAndGenerateDHKeysAsync(string invitationUsernameCopy) { lastInvitationStatus = InvitationStatus.WAITING_FOR_RESPONSE; bool userExists = model.CheckUserExist(invitationUsernameCopy); if (!userExists) { lastInvitationStatus = InvitationStatus.USER_NOT_FOUND; } else { bool userAlredyAFriend = false; foreach (FriendItem f in model.Friends) { if (f.Name == invitationUsernameCopy) { userAlredyAFriend = true; } } if (userAlredyAFriend) { lastInvitationStatus = InvitationStatus.USER_ALREADY_A_FRIEND; } else { (InvitationStatus invitationStatus, string g, string p, string invitationID) = model.SendInvitation(invitationUsernameCopy); lastInvitationStatus = invitationStatus; if (lastInvitationStatus == InvitationStatus.INVITATION_SENT) { RefreshFriendInvitationMessage(); (string publicDHKey, byte[] privateDHKey) = model.GenerateDHKeys(p, g); byte[] iv = Security.GenerateIV(); byte[] encryptedPrivateDHKey = Security.AESEncrypt(privateDHKey, model.UserKey, iv); string IVHexString = Security.ByteArrayToHexString(iv); string encryptedPrivateDHKeyHexString = Security.ByteArrayToHexString(encryptedPrivateDHKey); model.SendPublicDHKey(invitationID, publicDHKey, encryptedPrivateDHKeyHexString, IVHexString); } } } if (lastInvitationStatus != InvitationStatus.INVITATION_SENT) { RefreshFriendInvitationMessage(); } Thread.Sleep(3000); lastInvitationStatus = InvitationStatus.NO_INVITATION; RefreshFriendInvitationMessage(); }
/// <summary> /// 批量设置邀请状态 /// </summary> /// <param name="userId">请求接收人Id</param> /// <param name="status">需设置的请求状态</param> public void BatchSetStatus(long userId, InvitationStatus status) { //请求状态必须是接受或拒绝 if (status == InvitationStatus.Unhandled) return; IEnumerable<Invitation> invitations = GetTops(userId, int.MaxValue); if (invitations == null || invitations.Count() == 0) return; //触发事件 EventBus<Invitation>.Instance().OnBatchBefore(invitations, new CommonEventArgs(EventOperationType.Instance().Update())); invitationRepository.BatchSetStatus(userId, status); //触发事件 EventBus<Invitation>.Instance().OnBatchAfter(invitations, new CommonEventArgs(EventOperationType.Instance().Update())); }
/// <summary> /// 生成请求内容 /// </summary> /// <param name="Invitation">请求实体</param> /// <param name="status">请求状态</param> /// <returns>返回生成的请求内容</returns> public string Resolve(dynamic Invitation, InvitationStatus status) { if (Invitation == null) return string.Empty; if (!InvitationTemplates.ContainsKey(Invitation.InvitationTypeKey)) throw new ExceptionFacade(new ResourceExceptionDescriptor().WithContentNotFound("请求模板", Invitation.InvitationTypeKey)); InvitationTemplate invitationTemplate = InvitationTemplates[Invitation.InvitationTypeKey]; if (invitationTemplate == null) return string.Empty; string razorTemplate = string.Empty; switch (status) { case InvitationStatus.Unhandled: razorTemplate = invitationTemplate.UnhandledBody; break; case InvitationStatus.Accept: razorTemplate = invitationTemplate.AcceptBody; break; case InvitationStatus.Refuse: razorTemplate = invitationTemplate.RefuseBody; break; default: razorTemplate = invitationTemplate.UnhandledBody; break; } if (string.IsNullOrEmpty(razorTemplate)) return string.Empty; //使用RazorEngine解析请求内容 try { return Razor.Parse(razorTemplate, Invitation, Invitation.InvitationTypeKey); } catch (Exception e) { throw new ExceptionFacade(new CommonExceptionDescriptor("编译请求模板时报错"), e); } }
/// <summary> /// 批量设置请求的状态 /// </summary> /// <returns></returns> public string BatchSetStatus(string spaceKey, string invitationIds = null, InvitationStatus invitationStatus = InvitationStatus.Accept, int? pageIndex = 1, bool isPromp = false) { RouteValueDictionary routeValueDictionary = new RouteValueDictionary(); routeValueDictionary.Add("spaceKey", spaceKey); if (!string.IsNullOrEmpty(invitationIds)) routeValueDictionary.Add("invitationIds", invitationIds); routeValueDictionary.Add("invitationStatus", invitationStatus); if (pageIndex.HasValue && pageIndex != 1) routeValueDictionary.Add("pageIndex", pageIndex); if (isPromp) routeValueDictionary.Add("isPromp", isPromp); return CachedUrlHelper.Action("BatchSetStatus", "MessageCenter", CommonAreaName, routeValueDictionary); }
/// <summary> /// 更改一条请求的状态 /// </summary> /// <returns></returns> public string _InvitationSetStatus(string spaceKey, long id, InvitationStatus status = InvitationStatus.Accept) { RouteValueDictionary routeValueDictionary = new RouteValueDictionary(); routeValueDictionary.Add("spaceKey", spaceKey); routeValueDictionary.Add("id", id); routeValueDictionary.Add("status", status); return CachedUrlHelper.Action("_InvitationSetStatus", "MessageCenter", CommonAreaName, routeValueDictionary); }
/// <summary> /// 获取用户请求的分页集合 /// </summary> /// <param name="userId">用户Id</param> /// <param name="status">请求状态</param> /// <param name="invitationTypeKey">请求类型Key</param> /// <param name="applicationId">应用Id</param> /// <param name="pageIndex">页码</param> /// <returns>请求分页集合</returns> public PagingDataSet<Invitation> Gets(long userId, InvitationStatus? status, string invitationTypeKey, int? applicationId, int? pageIndex = null) { //按照创建日期倒序排序 return invitationRepository.Gets(userId, status, invitationTypeKey, applicationId, pageIndex); }
/// <summary> /// 设置邀请状态 /// </summary> /// <param name="id">请求id</param> /// <param name="status">需设置的请求状态</param> public void SetStatus(long id, InvitationStatus status) { //请求状态必须是接受或拒绝 if (status == InvitationStatus.Unhandled) return; Invitation invitation = Get(id); if (invitation == null) return; //触发事件 EventBus<Invitation>.Instance().OnBefore(invitation, new CommonEventArgs(EventOperationType.Instance().Update(), invitation.ApplicationId)); invitationRepository.SetStatus(invitation, status); //触发事件 EventBus<Invitation>.Instance().OnAfter(invitation, new CommonEventArgs(EventOperationType.Instance().Update(), invitation.ApplicationId)); }
public ActionResult PrompSetInvitations(string spaceKey, InvitationStatus status) { string[] invitationIds = Request.QueryString.Get("invitationIds", string.Empty).Split(new string[] { "=", "&", "invitationIds", "false", "," }, StringSplitOptions.RemoveEmptyEntries); foreach (string item in invitationIds) { long id; long.TryParse(item, out id); SetStatus(id, UserContext.CurrentUser.UserId, status); } return _ListPrompt(spaceKey); }
/// <summary> /// 设置一条信息状态 /// </summary> /// <param name="invitationId">请求id</param> /// <param name="userId">当前用户</param> /// <param name="status">状态</param> private void SetStatus(long invitationId, long userId, InvitationStatus status) { Invitation invitation = invitationService.Get(invitationId); if (invitation == null || invitation.UserId != userId || invitation.Status != InvitationStatus.Unhandled) return; invitationService.SetStatus(invitationId, status); }
/// <summary> /// 气泡中批量接受邀请 /// </summary> /// <param name="spaceKey">用户Key</param> /// <param name="invitationIds">被接受的邀请</param> /// <returns>链接</returns> public string PrompSetInvitations(string spaceKey, string invitationIds = null, InvitationStatus status = InvitationStatus.Accept) { RouteValueDictionary routeValueDictionary = new RouteValueDictionary(); routeValueDictionary.Add("spaceKey", spaceKey); if (!string.IsNullOrEmpty(invitationIds)) routeValueDictionary.Add("invitationIds", invitationIds); routeValueDictionary.Add("status", status); return CachedUrlHelper.Action("PrompSetInvitations", "MessageCenter", CommonAreaName, routeValueDictionary); }
/// <summary> /// 批量设置请求状态的方法 /// </summary> /// <param name="spaceKey">用户名</param> /// <param name="invitationIds">被设置的Id集合</param> /// <param name="invitationStatus">要设置成的状态</param> private void BatchSetStatus(IEnumerable<long> invitationIds, User user, InvitationStatus status) { foreach (int item in invitationIds) SetStatus(item, user.UserId, status); }
public ActionResult BatchSetStatus(string spaceKey, InvitationStatus invitationStatus = InvitationStatus.Accept, int pageIndex = 1) { pageResourceManager.InsertTitlePart("批量设置状态"); IEnumerable<string> invitationIds = Request.Form.Get("invitationIds", string.Empty).Split(new string[] { "=", "&", "invitationIds", "false", "," }, StringSplitOptions.RemoveEmptyEntries); IUser user = authenticationService.GetAuthenticatedUser(); foreach (string idstr in invitationIds) { long id; long.TryParse(idstr, out id); SetStatus(id, user.UserId, invitationStatus); } return ListInvitations(spaceKey, pageIndex); }
public ActionResult _InvitationSetStatus(string spaceKey, long id, InvitationStatus status) { pageResourceManager.InsertTitlePart("设置状态"); if (UserContext.CurrentUser == null) return HttpNotFound(); InvitationService invitationService = DIContainer.Resolve<InvitationService>(); Invitation invitation = invitationService.Get(id); User user = authenticationService.GetAuthenticatedUser() as User; SetStatus(id, user.UserId, status); ViewData["UnhandledCount"] = invitationService.GetUnhandledCount(UserIdToUserNameDictionary.GetUserId(spaceKey)); return PartialView(invitation); }