public override async Task <ActionResult> Index() { ViewResult view = (ViewResult)await base.Index(); //base.EvalCanCreate(); if (UserContact.IsInRole("GN_ADMIN")) { ViewBag.Organizations = db.GNOrganizations.SortBy("Name"); //.Where(a => a.OrganizationId.Equals(UserContact.GNOrganizationId)); } else { ViewBag.Organizations = db.GNOrganizations.Where(a => a.Id.Equals(UserContact.GNOrganizationId)).SortBy("Name"); } Dictionary <string, object> filters = new Dictionary <string, object>(); filters.Add("OrganizationId", Request["OrganizationId"]); filters.Add("projectId", Request["projectId"]); filters.Add("teamId", Request["teamId"]); List <GNAnalysisRequest> GNAnalysisRequests = await this.entityService.FindAll(UserContact, IndexStart(), IndexEnd(), filters); foreach (var analysisRequest in (IList <GNAnalysisRequest>)GNAnalysisRequests) { EvalActionPrivileges(analysisRequest); } return(View(GNAnalysisRequests)); }
public virtual void EvalCanCreate() { if (!UserContact.IsInRole("COLLABORATOR")) { ViewBag.CanCreate = true; } }
public async Task <ActionResult> MyBillingOverview() { if (UserContact != null && UserContact.IsInRole("GN_ADMIN")) { var remainingBudgets = await(new AccountService(db)).GetRemainingBudgetForAllAccounts(); } auditResult = audit.LogEvent(UserContact, Guid.Empty, this.ENTITY, this.Request.UserHostAddress, "LOAD_MY_BILLING_OVERVIEW_UI"); MyBillingCanAccess(); MyBillingOverviewModel model = new MyBillingOverviewModel(); InvoiceService invoiceService = new InvoiceService(this.db); AccountService accountService = new AccountService(this.db); model.MyAccount = GetMyAccount(); model.MyCurrentInvoice = await invoiceService.GetInvoiceForCurrentMonth(UserContact); model.MyLastInvoice = invoiceService.GetInvoiceForLastMonth(UserContact); model.MyBalancePastDue = accountService.GetBalancePastDue(UserContact, model.MyAccount, model.MyCurrentInvoice, model.MyLastInvoice); model.MaxApprovedSpend = accountService.GetTotalApprovedToSpend(UserContact, model.MyAccount); model.CurrentMonthSpend = -1 * model.MyCurrentInvoice.Total; model.MyRemainingBudget = (double)ViewBag.MyRemainingBudget; if (model.MyCurrentInvoice != null) { model.MyCurrentInvoice.TotalAppliedToPOs = invoiceService.GetInvoiceTotalPOApplied(model.MyCurrentInvoice.Id); model.MyAccount.TotalAppliedToPOs = model.MyCurrentInvoice.TotalAppliedToPOs; } if (model.MyLastInvoice != null) { model.MyLastInvoice.TotalAppliedToPOs = invoiceService.GetInvoiceTotalPOApplied(model.MyLastInvoice.Id); } //calc storage used model.MyStorageUsed = accountService.CalcStorageUsed(model.MyAccount.Id, DateTime.Now); //get storage carry over product info from DB GNProduct storageCarryOverProduct = this.db.GNProducts.Where(p => p.Name == "STORAGE_S3_CARRYOVER").FirstOrDefault(); model.StorageUnits = storageCarryOverProduct.ValueUnits; model.StoragePricePerUnit = storageCarryOverProduct.Price; model.MyStorageTotalCurrentCost = model.MyStorageUsed * model.StoragePricePerUnit; return(View(model)); }
public override GNProject PopulateSelectLists(GNProject project = null) { IQueryable <GNTeam> teams = null; if (project != null && project.Teams != null && project.Teams.FirstOrDefault() != null) { ViewBag.TeamsSize = 1; teams = db.GNTeams.Where(t => t.OrganizationId == UserContact.GNOrganizationId); ViewBag.TeamsList = new SelectList(teams, "Id", "Name", project.Teams.FirstOrDefault().Id); } else { var teamId = Request["teamId"]; if (string.IsNullOrEmpty(teamId)) { teamId = Request["TeamsList"]; } if (((ProjectService)entityService).aspNetRoleService.IsUserContactAdmin(UserContact) || UserContact.IsInRole("ORG_MANAGER")) { teams = db.GNTeams .Where(t => t.OrganizationId == UserContact.GNOrganizationId).OrderBy(a => a.Name); } else { teams = db.GNTeams .Where(t => t.OrganizationId == UserContact.GNOrganizationId) .Where(t => t.TeamMembers.Select(tm => tm.GNContactId).Contains(UserContact.Id)).OrderBy(a => a.Name); } ViewBag.TeamsSize = teams.Count(); ViewBag.TeamsList = new SelectList(teams, "Id", "Name", teamId); } if (project != null && (project.Teams == null || project.Teams.Count == 0) && teams != null && teams.Count() != 0) { project.Teams = teams.ToList(); } if (project != null && project.ProjectLead != null) { project.ProjectLeadId = project.ProjectLead.Id.ToString(); } EvalCanCreateAnalysisRequest(); return(base.PopulateSelectLists(project)); }
private ActionResult MyBillingCanAccess() { bool canAccess = false; if (UserContact.IsInRole("ORG_MANAGER") || UserContact.IsInRole("GN_ADMIN")) { canAccess = true; } if (!canAccess) { return(RedirectToAction("Index", "Home")); } return(View()); }
public override GNTemplate PopulateSelectLists(GNTemplate project = null) { IQueryable <GNOrganization> organizations = null; if (UserContact.IsInRole("GN_ADMIN")) { ViewBag.TeamsSize = 1; organizations = db.GNOrganizations; } else { organizations = db.GNOrganizations.Where(t => t.Id == UserContact.GNOrganizationId); } organizations = organizations.OrderBy(a => a.Name); ViewBag.GNOrganizationId = new SelectList(organizations, "Id", "Name", UserContact.GNOrganizationId); return(base.PopulateSelectLists(project)); }
public override GNContact PopulateSelectLists(GNContact entity) { string[] selectedRoles = null; if (entity != null) { if (entity.GNContactRoles != null) { selectedRoles = entity.GNContactRoles.Select(r => r.AspNetRoleId).ToArray(); } } IQueryable <AspNetRole> aspNetRoles = null; int UserMinHierarchyOrder = UserContact.GetUserMinHierarchyOrder(); if (UserContact.IsInRole("GN_ADMIN") || UserContact.IsInRole("ORG_MANAGER")) { aspNetRoles = this.identityDB.AspNetRoles.Where(r => r.Name != "GN_ADMIN" && !r.Name.Contains("GN_")); } else if (UserContact.IsInRole("TEAM_MANAGER")) { aspNetRoles = this.identityDB.AspNetRoles.Where(r => (!r.Name.Contains("GN_") && r.Name != "ORG_MANAGER") && r.HierarchyOrder > UserMinHierarchyOrder); } else { aspNetRoles = this.identityDB.AspNetRoles.Where(r => r.Name == "TEAM_MEMBER" && r.HierarchyOrder > UserMinHierarchyOrder); } ViewBag.AspNetRoleList = new MultiSelectList(aspNetRoles, "Id", "Name", selectedRoles); if (!string.IsNullOrEmpty(Request["organizationId"]) && entity != null) { entity.GNOrganization = db.GNOrganizations.Find(Guid.Parse(Request["organizationId"])); entity.GNOrganizationId = entity.GNOrganization.Id; } else if (!string.IsNullOrEmpty(Request["teamId"]) && entity != null) { entity.GNOrganization = db.GNTeams.Find(Guid.Parse(Request["teamId"])).Organization; entity.GNOrganizationId = entity.GNOrganization.Id; } else if (entity != null && entity.GNOrganizationId != Guid.Empty) { entity.GNOrganization = db.GNOrganizations.Find(entity.GNOrganizationId); } if (!string.IsNullOrEmpty(Request["aspNetUserId"]) && Guid.Parse(Request["aspNetUserId"]) != Guid.Empty) { if (entity == null) { entity = new GNContact(); } AspNetUser aspNetUser = identityDB.AspNetUsers.Find(Request["aspNetUserId"]); if (aspNetUser != null) { entity.User = aspNetUser; entity.AspNetUserId = aspNetUser.Id; entity.Email = aspNetUser.Email; } } return(base.PopulateSelectLists(entity)); }
public async Task <ActionResult> StartAnalysis(Guid analysisRequestId) { auditResult = audit.LogEvent(UserContact, analysisRequestId, this.ENTITY, this.Request.UserHostAddress, EVENT_START_ANALYSIS); try { //fetch analysis request from db var analysisRequest = this.db.GNAnalysisRequests .Include(ar => ar.GNAnalysisRequestGNSamples) .Include(ar => ar.GNAnalysisRequestGNSamples.Select(s => s.GNSample).Select(s => s.CloudFiles)) .Include(ar => ar.AnalysisStatus) .Include(ar => ar.AnalysisResult) .Where(ar => ar.Id == analysisRequestId) .FirstOrDefault(); //determine analysis actions allowed EvalActionPrivileges(analysisRequest); if (analysisRequest.CanStartAnalysis || analysisRequest.CanReStartAnalysis || UserContact.IsInRole("GN_ADMIN")) { await((AnalysisRequestService)entityService).StartAnalysis(UserContact, analysisRequestId); return(RedirectToAction("Details", new { id = analysisRequestId })); } else { return(RedirectToAction("Details", new { id = analysisRequestId })); } } catch (Exception ex) { if (ex.Message.ToLower().Contains("billing")) { return(RedirectToAction("NotAllowed", "Error")); } else { throw ex; } } }
public ActionResult Index() { auditResult = audit.LogEvent(UserContact, Guid.Empty, this.ENTITY, this.Request.UserHostAddress, "LOAD_DASHBOARD_UI"); ViewResult view = View(); IQueryable <GNAnalysisRequest> myAnalysisRequests = null; IQueryable <GNSample> mySamples = null; IQueryable <GNTeam> myTeams = null; IQueryable <GNProject> myProjects = null; IQueryable <GNSequencerJob> myOpenSequencerJobs = null; if (User.IsInRole("GN_ADMIN")) { myTeams = db.GNTeams; myProjects = db.GNProjects; myAnalysisRequests = db.GNAnalysisRequests; mySamples = db.GNSamples; myOpenSequencerJobs = db.GNSequencerJobs.Where(a => !a.Status.Equals("COMPLETED") && !a.Status.Equals("ERROR")); } else if (UserContact.IsInRole("ORG_MANAGER")) { myAnalysisRequests = db.GNAnalysisRequests .Where(a => a.Project.Teams.FirstOrDefault().OrganizationId == UserContact.GNOrganizationId); mySamples = db.GNSamples.Where(s => s.GNOrganizationId == UserContact.GNOrganizationId); myTeams = db.GNTeams.Where(t => t.OrganizationId == UserContact.GNOrganizationId); myProjects = db.GNProjects.Where(p => p.Teams.FirstOrDefault().OrganizationId == UserContact.GNOrganizationId); myOpenSequencerJobs = db.GNSequencerJobs.Where(a => a.GNOrganizationId == UserContact.GNOrganizationId && !a.Status.Equals("COMPLETED") && !a.Status.Equals("ERROR")); } else { myTeams = db.GNTeams .Where(t => ( t.OrganizationId == UserContact.GNOrganizationId && t.TeamMembers.Count(tm => tm.GNContactId == UserContact.Id) != 0 ) ); myProjects = myTeams.SelectMany(t => t.Projects); myAnalysisRequests = myProjects.SelectMany(p => p.AnalysisRequests); mySamples = db.GNSamples .Where(s => s.GNOrganizationId == UserContact.GNOrganizationId); myOpenSequencerJobs = db.GNSequencerJobs.Where(a => a.GNOrganizationId == UserContact.GNOrganizationId && !a.Status.Equals("COMPLETED") && !a.Status.Equals("ERROR")); } view.ViewData["RecentAnalysisRequests"] = myAnalysisRequests .OrderByDescending(ar => ar.AnalysisStatus.OrderByDescending(st => st.CreateDateTime).FirstOrDefault().CreateDateTime) .Take(5) .ToList(); view.ViewData["RecentSamples"] = mySamples .OrderByDescending(s => s.CreateDateTime) .Take(5) .ToList(); view.ViewData["MyProjects"] = myProjects .OrderByDescending(p => p.CreateDateTime) .Take(5) .ToList(); view.ViewData["MyTeams"] = myTeams .OrderByDescending(p => p.CreateDateTime) .Take(5) .ToList(); view.ViewData["myOpenSequencerJobs"] = myOpenSequencerJobs.Count(); EvalCanCreateAnalysisRequest(); EvalCanCreateSample(); EvalCanCreateProject(); EvalCanCreateTeam(); this.GetRemainingBudget(UserContact).ConfigureAwait(false); return(view); }