public async Task Add(IRole role) { TownGuild guild = Database.GetGuild(Context.Guild); if (guild == null) { return; } ActivityRole activity = guild.ActivityRoles.FirstOrDefault(x => x.AssociatedRole == role.Id); if (activity == null) { activity = new ActivityRole() { AssociatedRole = role.Id }; guild.ActivityRoles.Add(activity); } await ReplyAsync("Editing cross alert...\n" + $"Please answer the following questions ('{SkipCharacter}' to skip / leave default)"); await AskString($"What is the name of the activity?", activity.ActivityName, value => activity.ActivityName = value); await AskEnum("What type of activity? (Playing, Streaming, Listening, Watching)", activity.ActivityType, value => activity.ActivityType = value); Database.Guilds.Update(guild); await ReplyAsync("Done!"); }
public dtoResource(liteResource resource, String unknownUser) { IdResource = resource.Id; switch (resource.Type) { case Domain.ResourceType.Internal: if (resource.Person != null) { IdPerson = resource.Person.Id; LongName = resource.Person.SurnameAndName; ShortName = resource.GetShortName(); } else { LongName = unknownUser; } break; case Domain.ResourceType.External: case Domain.ResourceType.Removed: LongName = resource.LongName; ShortName = resource.ShortName; break; } DefaultForActivity = resource.DefaultForActivity; ProjectRole = resource.ProjectRole; }
public ActivityRole GetUserRoleByPage(ActivityRole role, PageContainerType container, PageListType currentPage) { switch (container) { case PageContainerType.Dashboard: if (currentPage == PageListType.DashboardResource) { return((role == ActivityRole.ProjectOwner || role == ActivityRole.Manager) ? ActivityRole.Resource : role); } else { return(role); } case PageContainerType.ProjectDashboard: if (currentPage == PageListType.ProjectDashboardResource) { return((role == ActivityRole.ProjectOwner || role == ActivityRole.Manager) ? ActivityRole.Resource : role); } else { return(role); } } return(role); }
private void AddRole(ActivityRole newRole) { if (GuildHandler.GetRole(newRole.id) == null) { throw new InvalidOperationException("No such role exists."); } _activityRoles.MutateValue(x => x.Add(newRole)); }
public dtoResource(dtoProjectResource resource) { IdResource = resource.IdResource; IdPerson = resource.IdPerson; LongName = resource.LongName; ShortName = resource.ShortName; DefaultForActivity = resource.DefaultForActivity; ProjectRole = resource.ProjectRole; }
private ActivityRole AttachmentGetContainerRole(Project project, PmActivity activity, ProjectResource resource, ModuleProjectManagement mPermission) { ActivityRole role = (resource != null) ? resource.ProjectRole : ((!project.isPersonal && mPermission.Administration) ? ActivityRole.Manager : ActivityRole.None); if (resource != null && activity != null && resource.Visibility == ProjectVisibility.InvolvedTasks && role != ActivityRole.Manager && role != ActivityRole.ProjectOwner) { if (activity.IsSummary) { role = (ResourceHasActivityAssignments(resource, activity) ? role : ActivityRole.None); } else { role = (activity.Assignments.Where(a => a.Deleted == BaseStatusDeleted.None && a.Resource == resource).Any()) ? role: ActivityRole.None; } } return(role); }
private static void AutoMapperActivity123() { Console.WriteLine("\nApplication Activity DTO -> Data -> DTO\n"); { Console.WriteLine("Activity"); EasyLOB.Activity.Data.Activity data = new EasyLOB.Activity.Data.Activity(); ActivityDTO dto = DIHelper.Mapper.Map <ActivityDTO>(data); data = DIHelper.Mapper.Map <EasyLOB.Activity.Data.Activity>(dto); } { Console.WriteLine("ActivityRole"); ActivityRole data = new ActivityRole(); ActivityRoleDTO dto = DIHelper.Mapper.Map <ActivityRoleDTO>(data); data = DIHelper.Mapper.Map <ActivityRole>(dto); } }
public dtoPlainProject(Project project, ActivityRole projectRole, ProjectVisibility visibility, Dictionary <ActivityRole, String> roleTranslations, Boolean alsoAsResource = false) { Id = project.Id; IsCompleted = project.IsCompleted; IdCommunity = (project.Community == null) ? (project.isPortal ? 0 : -1) : project.Community.Id; Name = project.Name; Completeness = project.Completeness; Status = project.Status; CommunityName = (project.Community != null) ? project.Community.Name:""; Deleted = project.Deleted; isPersonal = project.isPersonal; isPortal = project.isPortal; Deleted = project.Deleted; Visibility = visibility; Roles = new List <dtoProjectRole>(); Roles.Add(new dtoProjectRole() { ProjectRole = projectRole, LongName = roleTranslations[projectRole], ShortName = roleTranslations[projectRole].ToCharArray()[0].ToString() }); if (projectRole == ActivityRole.ProjectOwner) { Roles.Add(new dtoProjectRole() { ProjectRole = ActivityRole.Manager, LongName = roleTranslations[ActivityRole.Manager], ShortName = roleTranslations[ActivityRole.Manager].ToCharArray()[0].ToString() }); } if (alsoAsResource) { Roles.Add(new dtoProjectRole() { ProjectRole = ActivityRole.Resource, LongName = roleTranslations[ActivityRole.Resource], ShortName = roleTranslations[ActivityRole.Resource].ToCharArray()[0].ToString() }); } StartDate = project.StartDate; EndDate = project.EndDate; Deadline = project.Deadline; Availability = project.Availability; Permissions = new dtoProjectPermission(); Urls = new dtoProjectUrls(); ProjectAttachmentsCount = (project.Attachments != null ? project.Attachments.Where(a => a.Deleted == BaseStatusDeleted.None && a.IsForProject).LongCount() : 0); HasProjectAttachments = !(ProjectAttachmentsCount == 0); HasActivitiesAttachments = (project.AttachmentLinks != null && project.AttachmentLinks.Where(a => a.Deleted == BaseStatusDeleted.None && !a.IsForProject).Any()); }
public async Task Delete(IRole role) { TownGuild guild = Database.GetGuild(Context.Guild); if (guild == null) { return; } ActivityRole activity = guild.ActivityRoles.FirstOrDefault(x => x.AssociatedRole == role.Id); if (activity == null) { await ReplyAsync("Alert not found for " + role.Mention); } else { await ReplyAsync("Deleted activity for " + role.Mention); guild.ActivityRoles.Remove(activity); Database.Guilds.Update(guild); } }
public List <ProjectResource> AddResources(long idProject, List <dtoExternalResource> items, ProjectVisibility visibility, ActivityRole role, ref Int32 count) { count = items.Where(i => !string.IsNullOrEmpty(i.LongName) || !string.IsNullOrEmpty(i.ShortName)).Count(); if (UserContext.isAnonymous) { View.DisplayRows(View.Rows, View.AllowMail, UserContext.isAnonymous); return(null); } else { return(Service.AddExternalResources(idProject, items, visibility, role)); } }
private void AddRole(ActivityRole role) { _activityRoles.MutateValue(x => x.Add(role)); SortRoles(); }