Exemplo n.º 1
0
 //Get pledges by project id single project view
 public List <Pledge> GetPledgesByProjectId(int projectId)
 {
     return(_db.Set <Pledge>()
            .Include(p => p.PledgeUsers)
            .Where(p => p.Project.ProjectId == projectId)
            .ToList());
 }
Exemplo n.º 2
0
        public async Task <IActionResult> GetAllProjects(string projectCategory, string searchString)
        {
            //Use LINQ to get list of genres.
            IQueryable <string> categoryQuery = from m in _db.Set <Project>()
                                                orderby m.ProjectCategory
                                                select m.ProjectCategory;
            var viewallprojects = new ProjectsGridVM
            {
                Categories        = new SelectList(await categoryQuery.Distinct().ToListAsync()),
                Projects          = _projectservices.GetAllActiveProjects(projectCategory, searchString).ToList(),
                ProjectMultimedia = _multimediaServices.GetAll()
            };

            return(View(viewallprojects));
        }
Exemplo n.º 3
0
        public IQueryable <Fund> GetUserFunds()
        {
            string userId = httpContextAccessor.HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier);
            var    result = _db.Set <Fund>()
                            .Include(p => p.Project)
                            .Where(p => p.UserId == userId)
                            .Distinct()
                            .AsQueryable();

            if (result == null)
            {
                return(null);
            }
            return(result);
        }
Exemplo n.º 4
0
        public Result <Post> UpdatePost(PostOptions postOptions)
        {
            if (postOptions == null)
            {
                return(Result <Post> .CreateFailed(
                           StatusCode.BadRequest, "Null options"));
            }

            if (string.IsNullOrWhiteSpace(postOptions.PostDescription))
            {
                return(Result <Post> .CreateFailed(
                           StatusCode.BadRequest, "Null or empty PostDescription"));
            }

            //string userId = httpContextAccessor.HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier);

            var post = _db.Set <Post>().Find(postOptions.PostId);

            post.PostDescription = postOptions.PostDescription;


            var rows = 0;

            try
            {
                rows = _db.SaveChanges();
            }
            catch (Exception ex)
            {
                return(Result <Post> .CreateFailed(
                           StatusCode.InternalServerError, ex.ToString()));
            }

            if (rows <= 0)
            {
                return(Result <Post> .CreateFailed(
                           StatusCode.InternalServerError,
                           "Post could not be updated"));
            }

            return(Result <Post> .CreateSuccessful(post));
        }
Exemplo n.º 5
0
        //GetMultimediaOfProject(int projectId);



        public List <Multimedia> GetMultimediaOfProject(int projectId)
        {
            return(_db.Set <Multimedia>()
                   .Where(p => p.Project.ProjectId == projectId)
                   .ToList());
        }