Beispiel #1
0
        public IQueryable <Backer> SearchBacker(SearchBaker options)
        {
            var backer_ = context_
                          .Set <Backer>()
                          .AsQueryable();


            if (options == null)
            {
                return(null);
            }

            if (!string.IsNullOrWhiteSpace(options.Email))
            {
                backer_ = backer_.Where(c =>
                                        c.Email == options.Email);
            }

            if (!string.IsNullOrWhiteSpace(options.FirstName))
            {
                backer_ = backer_.Where(c =>
                                        c.FirstName == options.FirstName);
            }

            if (!string.IsNullOrWhiteSpace(options.LastName))
            {
                backer_ = backer_.Where(c =>
                                        c.LastName == options.LastName);
            }

            return(backer_);
        }
        public IQueryable <Creator> SearchCreator(SearchCreatorOptions options)
        {
            var query = context_
                        .Set <Creator>()
                        .AsQueryable();

            if (options == null)
            {
                return(null);
            }

            if (options.Id != null)
            {
                return(query.Where(s => s.Id == options.Id));
            }


            if (!string.IsNullOrWhiteSpace(options.Email))
            {
                query = query.Where(s => s.Email == options.Email);
            }

            if (options.FirstName != null)
            {
                query = query
                        .Where(s => s.FirstName == options.FirstName);
            }

            if (options.LastName != null)
            {
                query = query
                        .Where(s => s.LastName == options.LastName);
            }

            return(query
                   .Take(500));
        }
Beispiel #3
0
        public IQueryable <Project> SearchProject(SearchProjects options)
        {
            var project_ = context_
                           .Set <Project>()
                           .AsQueryable();

            if (options == null)
            {
                return(null);
            }

            if (!string.IsNullOrWhiteSpace(options.Title))
            {
                project_ = project_.Where(p =>
                                          p.Tittle == options.Title);
            }

            if (options.Id <= 0)
            {
                project_ = project_.Where(p =>
                                          p.id == options.Id);
            }
            return(project_);
        }
        public async Task <ApiResult <Reward> > UpdateRewardServiceAsync(int id, UpdateReward options)
        {
            if (id < 1)
            {
                return(new ApiResult <Reward>(
                           StatusCode.BadRequest, $"not valid {id}"));
            }

            var result = await context_
                         .Set <Reward>()
                         .Where(t => t.ProjectId == id)
                         .SingleOrDefaultAsync();

            if (result == null)
            {
                return(new ApiResult <Reward>(
                           StatusCode.NotFound, $"this {result} dont exist"));
            }

            return(ApiResult <Reward> .CreateSuccess(result));
        }