예제 #1
0
        public async Task <ServiceStatusListItem <MyTask> > MyTaskSearchAsync([FromQuery] FilterItem filter)
        {
            ServiceStatusListItem <MyTask> result = new ServiceStatusListItem <MyTask>();

            try
            {
                var items = _manager.TaskSearch(filter);
                if (items != null)
                {
                    result.Data = items.ToList();
                }
                if (result.Data?.Count > 0)
                {
                    result.AddSuccess($"Readed page: {filter.Page}, items: {result.Data.Count}");
                }
                else
                {
                    result.AddSuccess("no data");
                }
                result.Success = true;
            }
            catch (Exception ex)
            {
                result.AddError(ex);
            }
            return(result);
        }
예제 #2
0
        public async Task <ServiceStatusListItem <CategoryItem> > CategoryAllAsync()
        {
            ServiceStatusListItem <CategoryItem> result = new ServiceStatusListItem <CategoryItem>();

            try
            {
                result.Data = new List <CategoryItem>();
                using (var db = new DBCommand(_connectionString, Queries.Categories))
                {
                    result.ReturnValue = await db.ExecuteReaderWhileAsync((dr, rowNumber) =>
                    {
                        result.Data.Add(new CategoryItem
                        {
                            ID       = dr.GetInt("ID"),
                            Category = dr.GetString("Category"),
                            Color    = dr.GetString("Color")
                        });
                    });
                }
                result.Success = true;
            }
            catch (Exception ex)
            {
                result.AddError(ex);
            }
            return(result);
        }
        public async Task <ServiceStatusListItem <Category> > Get()
        {
            ServiceStatusListItem <Category> result = new ServiceStatusListItem <Category>();

            try
            {
                result.Data    = _manager.CategoryGetAllAsync().ToList();
                result.Success = true;
            }
            catch (Exception ex)
            {
                result.AddError(ex);
            }
            return(result);
        }
        public async Task <ServiceStatusListItem <Statistic> > Get()
        {
            ServiceStatusListItem <Statistic> result = new ServiceStatusListItem <Statistic>();

            try
            {
                result.Data    = _manager.StatisticGetAll().ToList();
                result.Success = true;
            }
            catch (Exception ex)
            {
                result.AddError(ex);
            }
            return(result);
        }
예제 #5
0
        public async Task <ServiceStatusListItem <TodoItem> > TodoSearchAsync(FilterItem filter)
        {
            ServiceStatusListItem <TodoItem> result = new ServiceStatusListItem <TodoItem>();

            try
            {
                int startIndex = (filter.Page - 1) * filter.Size;

                result.Data = new List <TodoItem>();
                using (var db = new DBCommand(_connectionString, Queries.Search, true))
                {
                    db.AddParameterInt("@startIndex", startIndex);
                    db.AddParameterInt("@pageSize", filter.Size);
                    db.AddParameterStringNull("@text", 100, filter.Text);
                    db.AddParameterInt("@idCategory", filter.IDCategory);
                    db.AddParameterInt("@status", filter.Status);
                    db.AddParameterString("@sort", 100, filter.Sort);

                    result.ReturnValue = await db.ExecuteReaderWhileAsync((dr, rowNumber) =>
                    {
                        result.Data.Add(new TodoItem
                        {
                            ID         = dr.GetInt("id"),
                            Date       = dr.GetDateTime("date"),
                            Title      = dr.GetString("title"),
                            IDCategory = dr.GetInt("idCategory"),
                            Category   = dr.GetString("category"),
                            Color      = dr.GetString("color"),
                            Completed  = dr.GetDateTimeNull("completed"),
                            Modified   = dr.GetDateTime("modified"),
                            Created    = dr.GetDateTime("created"),
                            TotalItems = dr.GetInt("totalItems")
                        });
                    });
                }
                result.Success = true;
            }
            catch (Exception ex)
            {
                result.AddError(ex);
            }
            return(result);
        }