public IActionResult Summary([FromHeader(Name = "Access-Token")] string accessToken) { string clientIpAddress = this.HttpContext.Connection.RemoteIpAddress.ToString(); _logger.LogInformation($"{clientIpAddress}: Method call to ( /api/admin/clients )"); _storage.IpWatchList[clientIpAddress].MethodCallTally++; switch (_security.ValidateAccessToken(clientIpAddress, accessToken ?? string.Empty)) { case Security.AccessLevel.None: _storage.IpWatchList[clientIpAddress].FailedAttempts++; _logger.LogInformation($"{clientIpAddress}: invalid access token"); return(Unauthorized()); case Security.AccessLevel.User: _storage.IpWatchList[clientIpAddress].FailedAttempts++; _logger.LogInformation($"{clientIpAddress}: insufficient access token"); return(Unauthorized()); } var clientSummary = new ClientSummary(); foreach (var key in _storage.IpWatchList.Keys) { clientSummary.Clients.Add(_storage.IpWatchList[key]); } return(Ok(clientSummary)); }
public ActionResult Index(string sort) { var clientList = _clientManager.GetClientSummary(DateTime.Now.AddMonths(-6)) .Select(i => { ClientSummary clientSummary = Mapper.Map <Models.Client.ClientSummary>(i); return(clientSummary); }); if (!string.IsNullOrEmpty(sort)) { if (sort == "hours") { clientList = clientList.OrderByDescending(i => i.TotalHoursLogged); } else if (sort == "alpha") { clientList = clientList.OrderBy(i => i.ClientName); } else { clientList = clientList.OrderByDescending(i => i.LastHoursLogged); } } else { clientList = clientList.OrderByDescending(i => i.LastHoursLogged); } return(View(clientList.ToList())); }
private void DeleteClient(ClientSummary client) { if (client == null) { return; } PopupService.DisplayQuestion("Suppression de client", $"Etes-vous certain de vouloir supprimer le client {client.LastName} {client.FirstName}", QuestionActionButton.Yes(() => DeleteClientConfirmed(client)), QuestionActionButton.No()); }
public void Initialize(ClientSummary clientSummary) { _isUnsavedNewClient = false; if (clientSummary == null) { throw new ArgumentNullException(nameof(clientSummary)); } LoadClientAsync(clientSummary.Id); }
private void EditClient(ClientSummary client) { if (client == null) { return; } // Display client Mediator.Default.Send(new SwitchToDisplayClientMessage { Client = SelectedClient }); }
protected void ConfigureQueryClients(int number) { var clients = new ClientSummary[number]; for (var i = 0; i < number; i++) { clients[i] = new ClientSummary { Subject = i.ToString(), ClientName = string.Format("name{0}", i), ClientId = string.Format("id{0}", i) }; } ClientServiceImpl.SetupQueryClientsAsync(new QueryResult <ClientSummary> { Items = clients }); }
private void HandleSaveClientMessage(SaveClientMessage msg) { // Refresh client summary ClientSummary existingSummary = Clients?.FirstOrDefault(x => x.Id == msg.Client.Id); if (existingSummary != null) { existingSummary.Initialize(msg.Client); } else { ClientSummary clientSummary = new ClientSummary(msg.Client); Clients = Clients ?? new ObservableCollection <ClientSummary>(); Clients.Insert(0, clientSummary); // insert at the beginning } }
public Task <IdentityAdminResult <QueryResult <ClientSummary> > > QueryClientsAsync(string filter, int start, int count) { using (var db = new ConfigurationDbContext(connection)) { var query = from client in db.Clients orderby client.ClientName select client; if (!String.IsNullOrWhiteSpace(filter)) { query = from client in query where client.ClientName.Contains(filter) orderby client.ClientName select client; } int total = query.Count(); var clients = query.Skip(start).Take(count).ToArray(); var result = new QueryResult <ClientSummary>(); result.Start = start; result.Count = count; result.Total = total; result.Filter = filter; result.Items = clients.Select(x => { var client = new ClientSummary { Subject = x.Id.ToString(), ClientName = x.ClientName, ClientId = x.ClientId }; return(client); }).ToArray(); return(Task.FromResult(new IdentityAdminResult <QueryResult <ClientSummary> >(result))); } }
public ClientSummary GetClientSummary(string id) { ClientHeader clientHeader = null; ClientSummary clientSummary = null; if (Guid.TryParse(id, out Guid parsedId)) { clientHeader = _unitOfWork.ClientHeaders.GetClientHeaderWithRelations(parsedId, true); } else { clientHeader = _unitOfWork.ClientHeaders.GetClientHeaderWithRelations(id, true); } if (clientHeader != null) { clientSummary = new ClientSummary() { Id = clientHeader.Id, ShortName = clientHeader.ShortName, LongName = clientHeader.LongName, }; var mainContact = clientHeader.ClientContacts.Where(c => c.MainContact == true).SingleOrDefault(); if (mainContact != null) { clientSummary.ContactId = mainContact.Id; clientSummary.MainContactName = $"{mainContact.FirstName} {mainContact.LastName}"; clientSummary.Phone = mainContact.Phone; clientSummary.Email = mainContact.Email; } } return(clientSummary); }
private void DeleteClientConfirmed(ClientSummary client) { ClientBL.DeleteClient(client.Id); Clients.Remove(client); PopupService.DisplayQuestion("Confirmation de la suppression", "Le client a été supprimé", QuestionActionButton.Ok()); }
public async Task <IActionResult> OnGetAsync() { var accessToken = await HttpContext.GetTokenAsync("access_token"); await PageConstructor(SaveStates.IGNORE, accessToken); if (!await _apiHelper.AuthCheck(accessToken, User.FindFirst("sub").Value)) { return(RedirectToPage("/Logout")); } taskGroupSummary = new TaskGroupSummary(); clientSummary = new ClientSummary(); if (!string.IsNullOrWhiteSpace(Id)) { var response = await _apiHelper.MakeAPICallAsync(accessToken, HttpMethod.Get, APITypes.TASK, $"TaskGroup/GetTaskGroupSummary/{Id}"); if (response.StatusCode == System.Net.HttpStatusCode.OK) { taskGroupSummary = response.ContentAsType <TaskGroupSummary>(); } else { return(RedirectToPage("/TaskGroup/TaskGroups")); } } else { return(RedirectToPage("/TaskGroup/TaskGroups")); } if (taskGroupSummary != null) { await GetFileLinks(accessToken); var response = await _apiHelper.MakeAPICallAsync(accessToken, HttpMethod.Get, APITypes.CLIENT, $"Client/GetClientSummary/{taskGroupSummary.ClientHeaderId}"); if (response.StatusCode == System.Net.HttpStatusCode.OK) { clientSummary = response.ContentAsType <ClientSummary>(); } GanttDataModel = GanttHelper.GenerateGanttDataModel(taskGroupSummary); } else { GanttDataModel = new GanttDataModel() { Data = new GanttData[0], Links = new GanttLink[0] }; } var userList = await GetUsernames(accessToken); //Temporary fix for adding language code data to partial pages. taskGroupSummary.langQueryList = taskGroupSummarylangQueryList; taskGroupSummary.MainUserName = userList.Users.Where(u => u.Id == taskGroupSummary.MainUserId).FirstOrDefault().FullName; foreach (var childTaskGroupSummary in taskGroupSummary.ChildTaskGroups) { childTaskGroupSummary.langQueryList = taskGroupSummarylangQueryList; childTaskGroupSummary.MainUserName = userList.Users.Where(u => u.Id == childTaskGroupSummary.MainUserId).FirstOrDefault().FullName; foreach (var childTaskSummary in childTaskGroupSummary.ChildTasks) { childTaskSummary.langQueryList = taskSummarylangQueryList; childTaskSummary.MainUserName = userList.Users.Where(u => u.Id == childTaskSummary.MainUserId).FirstOrDefault().FullName; } } foreach (var childTaskSummary in taskGroupSummary.ChildTasks) { childTaskSummary.langQueryList = taskGroupSummarylangQueryList; childTaskSummary.MainUserName = userList.Users.Where(u => u.Id == childTaskSummary.MainUserId).FirstOrDefault().FullName; } GanttJSON = JsonSerializer.Serialize(GanttDataModel); SaveMessageModel = await _apiHelper.GenerateSaveMessageModel(accessToken); return(Page()); }