public PlanificationPageViewModel(INavigationService navigationService, ISqliteService sqliteService) : base(navigationService) { Pills = sqliteService.Get <Pill>().Result; Pill = Pills[0]; StartDate = DateTime.Today; Periodicities = new List <Periodicity>() { new Periodicity { Id = (int)PlanificationType.Daily, Description = "Diaria", NextPage = "DailyPlanificationPage" }, new Periodicity { Id = (int)PlanificationType.Weekly, Description = "Semanal", NextPage = "WeeklyPlanificationPage" }, new Periodicity { Id = (int)PlanificationType.Custom, Description = "Personalizada", NextPage = "CustomPlanificationPage" } }; Periodicity = Periodicities[0]; CriticalStock = "0"; QtyToDispense = "1"; CancelCommand = new DelegateCommand(async() => await NavigationService.GoBackAsync()); NextCommand = new DelegateCommand(async() => await NextAsync()); }
public void Set(string surveyId) { var surveys = _sqlite.Get(); var survey = surveys.FirstOrDefault(s => s.SurveyId == surveyId); if (survey.IsFavourite) { survey.IsFavourite = false; survey.Image = AppConst.UnSelectFavourite; } else { survey.IsFavourite = true; survey.Image = AppConst.SelectFavourite; } _sqlite.Update(survey); }
public ManagerPage() { InitializeComponent(); switchOnListen = true; ToolbarItems.Add(new ToolbarItem("Delete", "", () => { _sqlite.DeleteAll(); })); ToolbarItems.Add(new ToolbarItem("StopListen", "", () => { Task.Run(async() => await SendMessage("managerId", "stop")); switchOnListen = false; })); Device.StartTimer(TimeSpan.FromSeconds(5), () => { Task.Run(async() => await SendMessage("managerId", "start")); return(switchOnListen); }); Device.StartTimer(TimeSpan.FromSeconds(5), () => { return(true); }); _sqlite = DependencyService .Get <ISqliteService <InterviewerEntity> >(); var client = new ClientHandler("Manager", "SendMessageInterviewer"); Task.Run(async() => await client.StartAsync()); var interviewer = new Label(); var watchGrid = new Grid(); client.Message += (sender, e) => { if (e.Id != "managerId") { var interviewerEntity = new InterviewerEntity { InterviewerId = e.Id }; var interviewerExist = _sqlite.Get().Any(x => x.InterviewerId == e.Id); var initialInterviewerCount = _sqlite.Get().Count(); if (!interviewerExist) { _sqlite.Add(interviewerEntity); } var interviewerAddedCount = _sqlite.Get().Count(); Device.BeginInvokeOnMainThread(() => { var stack = new StackLayout(); int numberOfRows = watchGrid.RowDefinitions.Count; var column = 0; var row = 0; if (numberOfRows > 0) { var numberOfChildren = watchGrid.Children.Count; if (interviewerAddedCount % 2 != 0 && initialInterviewerCount != interviewerAddedCount) { watchGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(600) }); } for (int childIndex = 0; childIndex < numberOfChildren; ++childIndex) { var view = watchGrid.Children[childIndex]; var element = ((StackLayout)view).Children.ElementAt(0); row = Grid.GetRow(watchGrid.Children[childIndex]); column = Grid.GetColumn(watchGrid.Children[childIndex]); if (interviewerAddedCount % 2 != 0 && initialInterviewerCount != interviewerAddedCount) { row++; } if (((Label)element).Text == e.Id) { watchGrid.Children.RemoveAt(childIndex); stack = new ContentViewBuilder().Build(e.Message, e.Id); watchGrid.Children.Add(stack, column, row); break; } if (((Label)element).Text != e.Id && row == Grid.GetRow(watchGrid.Children[childIndex]) && initialInterviewerCount != interviewerAddedCount) { stack = new ContentViewBuilder().Build(e.Message, e.Id); watchGrid.Children.Add(stack, column + 1, row); break; } if (((Label)element).Text != e.Id && row != Grid.GetRow(watchGrid.Children[childIndex]) && initialInterviewerCount != interviewerAddedCount) { stack = new ContentViewBuilder().Build(e.Message, e.Id); watchGrid.Children.Add(stack, column, row); break; } } } else { watchGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(300) }); watchGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(300) }); watchGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(600) }); stack = new ContentViewBuilder().Build(e.Message, e.Id); watchGrid.Children.Add(stack, 0, 0); } Content = watchGrid; }); } }; }
public IEnumerable <SurveyDetailsEntity> GetList() { var surveys = _sqlite.Get(); return(surveys.OrderByDescending(o => o.IsFavourite)); }
public Item Get(string id) { return(Guid.TryParse(id, out Guid key) ? _sqliteService.Get <Item>(key) : default);
private IEnumerable <ProcessEntity> Get() { var entities = _sqlite.Get(); return(entities.OrderByDescending(x => x.Id).ToList() ?? new List <ProcessEntity>()); }
public ServerEntity Get() { return(_sqliteService.Get().FirstOrDefault()); }