Ejemplo n.º 1
0
 public void Post(int id, NewPortfolioBindingModel port)
 {
     if (ModelState.IsValid)
     {
         //Check if state is valid
         _portfolioServ.MakePortfolio(id, port);
     }
 }
Ejemplo n.º 2
0
        public void MakePortfolio(int projectId, NewPortfolioBindingModel port)
        {
            var uploads = (from p in _uploadRepo.FindUploadsByProjectId(projectId)
                           where port.PictureIds.Contains(p.Id)
                           select p).ToList();
            var project = _projectRepo.Get(projectId).FirstOrDefault();

            var portfolio = new Portfolio()
            {
                Uploads      = uploads,
                Description  = project.Description,
                AfterPicture = (from p in uploads
                                where p.Id == port.AfterId
                                select p).FirstOrDefault(),
                BeforePicture = (from p in uploads
                                 where p.Id == port.BeforeId
                                 select p).FirstOrDefault(),
                Name      = project.Title,
                ProjectId = project.Id
            };

            _portfolioRepo.Add(portfolio);
            _portfolioRepo.SaveChanges();
        }