public async void GetClientStatusesAsync()
 {
     if (position == 0)
     {
         Statuses.AddRange(await SqliteUtil.Current.QueryStatuses(pageSize));
     }
 }
Exemple #2
0
        public void SetStatuses(string[] active, string[] inactive)
        {
            List <string> validActive = active.Where(x => !String.IsNullOrEmpty(x))
                                        .Distinct()
                                        .ToList();

            if (validActive.Count == 0)
            {
                throw new Exception("Project must contain at least one Active status.");
            }

            List <string> validInactive = inactive.Where(x => !String.IsNullOrEmpty(x))
                                          .Distinct()
                                          .ToList();

            if (validInactive.Count == 0)
            {
                throw new Exception("Project must contain at least one Inactive status.");
            }

            string[] intersection = validActive.Intersect(validInactive).ToArray();
            if (intersection.Length > 0)
            {
                throw new Exception(String.Format("Status(es) cannot be both Active and Inactive: {0}", String.Join(", ", intersection)));
            }

            Statuses.Clear();
            Statuses.AddRange(validActive.Select(x => new Status(x, true)));
            Statuses.AddRange(validInactive.Select(x => new Status(x, false)));
        }
        async Task ExecuteRefreshCommandAsync()
        {
            var result = await StoreManager.StatusesService.GetStatusesAsync(position, pageIndex, pageSize);

            if (result.Success)
            {
                var statuses = JsonConvert.DeserializeObject <List <Statuses> >(result.Message.ToString());
                if (statuses.Count > 0)
                {
                    if (pageIndex == 1 && Statuses.Count > 0)
                    {
                        Statuses.Clear();
                    }
                    Statuses.AddRange(statuses);

                    if (position == 0)
                    {
                        await SqliteUtil.Current.UpdateStatuses(statuses);
                    }
                    pageIndex++;
                    if (Statuses.Count >= pageSize)
                    {
                        LoadStatus  = LoadMoreStatus.StausDefault;
                        CanLoadMore = true;
                    }
                    else
                    {
                        LoadStatus  = LoadMoreStatus.StausEnd;
                        CanLoadMore = false;
                    }
                }
                else
                {
                    CanLoadMore = false;
                    LoadStatus  = pageIndex > 1 ? LoadMoreStatus.StausEnd : LoadMoreStatus.StausNodata;
                }
            }
            else
            {
                Log.SaveLog("StatusesViewModel.GetStatusesAsync", new Exception()
                {
                    Source = result.Message
                });
                LoadStatus = pageIndex > 1 ? LoadMoreStatus.StausError : LoadMoreStatus.StausFail;
            }
        }
Exemple #4
0
        private async Task LoadAllStatusAsync()
        {
            var statuses = await _statusDataAccess.GetAllStatus();

            Statuses.AddRange(_mapper.Map <List <StatusModel> >(statuses));
        }
Exemple #5
0
        private async Task GenerateList(int?statusId = null)
        {
            var allStatus = await context.Statuses.ToListAsync();

            Statuses.AddRange(allStatus.OrderBy(p => p.Name));

            Statuses.Add(DefaultStatus);
            if (!statusId.HasValue)
            {
                var defaultStats = Statuses.FirstOrDefault(p => p.Name.Equals("Assigned"));
                if (defaultStats != null)
                {
                    ActiveStatusId = defaultStats.Id;
                }
            }
            else
            {
                ActiveStatusId = statusId.Value;
            }


            IList <TicketListItemDto> ticketResult = new List <TicketListItemDto>();

            ticketResult = await ticketService.GetAllTicketsAsync(ActiveStatusId);

            if (ticketResult.Any())
            {
                TicketBody.TicketList = ticketResult;
            }

            TicketHeader.ReportedBy.Add(DefaultListItem);

            var reportedByList = await ticketService.GetAllNamesOfReportedBy();

            TicketHeader.ReportedBy.AddRange(reportedByList.Select(p => new SelectListItem
            {
                Selected = p.Equals(Filter.ReportedBy),
                Text     = p,
                Value    = p
            }).ToList());

            TicketHeader.PropertySort = TicketPropertyNames().ToList();

            TicketHeader.AssignedTo.Add(DefaultListItem);

            TicketHeader.AssignedTo.AddRange(await context.Users.Select(p => new SelectListItem
            {
                Selected = p.Id == Filter.AssignedToId,
                Text     = $"{p.FirstName} {p.LastName}",
                Value    = p.Id.ToString()
            }).ToListAsync());

            TicketHeader.CreatedBy.Add(DefaultListItem);

            TicketHeader.CreatedBy.AddRange(await context.Users.Select(p => new SelectListItem
            {
                Selected = p.Id == Filter.CreatedById,
                Text     = $"{p.FirstName} {p.LastName}",
                Value    = p.Id.ToString()
            }).ToListAsync());

            TicketHeader.Priorities.Add(DefaultListItem);
            TicketHeader.Priorities = await context.Priorities.Select(p => new SelectListItem
            {
                Selected = p.Id == Filter.PriorityId,
                Text     = p.Name,
                Value    = p.Id.ToString()
            }).ToListAsync();
        }