Example #1
0
        public IHttpActionResult GetPortfolioDetail(int id)
        {
            PortfolioDetail portfolioDetail = DAL.GetPortfolio(id);

            if (portfolioDetail == null)
            {
                return(NotFound());
            }

            return(Ok(portfolioDetail));
        }
Example #2
0
 public IHttpActionResult PutPortfolioDetail(int id, PortfolioDetail portfolioDetail)
 {
     try
     {
         DAL.UpdatePortfolioDetails(portfolioDetail);
     }
     catch (DbUpdateConcurrencyException ex)
     {
         throw ex;
     }
     return(StatusCode(HttpStatusCode.NoContent));
 }
Example #3
0
        public IHttpActionResult PostPortfolioDetail(PortfolioDetail portfolioDetail)
        {
            // DAL.AddPortfolioDetails(portfolioDetail);
            //string imageName = null;
            var httpRequest = HttpContext.Current.Request;
            //upload image
            var postedFile = httpRequest.Files["Image"];
            var fileName   = portfolioDetail.CoverImage.Split('\\');
            //create custom filename
            // imageName = new string(Path.GetFileNameWithoutExtension(postedFile.FileName).Take(10).ToArray()).Replace(" ", "-");
            // imageName = imageName + DateTime.Now.ToString("yymmssfff") + Path.GetExtension(postedFile.FileName);
            var filePath = HttpContext.Current.Server.MapPath("~/Image/" + fileName.LastOrDefault());

            //postedFile.SaveAs(filePath);

            using (CompanyPortfolioEntities db = new CompanyPortfolioEntities())
            {
                //PortfolioDetail portfolioDetail = new PortfolioDetail()
                //{
                //    //CoverImage = httpRequest["CoverImage"]
                //   // PortfolioID = 0,
                //    PortfolioName = "",
                //    CompanyID = 0,
                //    PortfolioDescription = "",

                //     CoverImage = filePath,
                //    YouTubeUrl = ""


                //};
                //db.PortfolioDetails.Add(portfolioDetail);
                //db.SaveChanges();

                var customers = db.PortfolioDetails.Add(new PortfolioDetail {
                    CoverImage = fileName.LastOrDefault(), PortfolioName = portfolioDetail.PortfolioName, CompanyID = portfolioDetail.CompanyID, PortfolioDescription = portfolioDetail.PortfolioDescription, YouTubeUrl = portfolioDetail.YouTubeUrl
                });
                // customers.Add(new Customer { CustomerId = id, Name = "John Doe" });

                db.SaveChanges();
            }
            // return Request.CreateResponse(HttpStatusCode.Created);


            return(CreatedAtRoute("DefaultApi", new { id = portfolioDetail.PortfolioID }, portfolioDetail));
        }
Example #4
0
 private static void SetOriginalValue(int entityId, Table t, Field f, Translation translation)
 {
     if (t == Table.Articles)
     {
         IArticleRepository repository = DependencyResolver.Current.GetService <IArticleRepository>();
         Article            item       = repository.GetById(entityId);
         if (item != null && f == Field.Name)
         {
             translation.Original = item.Name;
         }
         if (item != null && f == Field.Description)
         {
             translation.Original = item.Description;
         }
     }
     if (t == Table.Certificates)
     {
         ICertificatesRepository repository = DependencyResolver.Current.GetService <ICertificatesRepository>();
         Certificate             item       = repository.GetById(entityId);
         if (item != null && f == Field.Name)
         {
             translation.Original = item.Name;
         }
     }
     if (t == Table.Contacts)
     {
         IContactsRepository repository = DependencyResolver.Current.GetService <IContactsRepository>();
         Contact             item       = repository.GetById(entityId);
         if (item != null && f == Field.Name)
         {
             translation.Original = item.Name;
         }
         if (item != null && f == Field.Description)
         {
             translation.Original = item.Description;
         }
     }
     if (t == Table.Languages)
     {
         ILanguagesRepository repository = DependencyResolver.Current.GetService <ILanguagesRepository>();
         Language             item       = repository.GetById(entityId);
         if (item != null && f == Field.Name)
         {
             translation.Original = item.Name;
         }
     }
     if (t == Table.PortfolioDetails)
     {
         IPortfolioDetailsRepository repository = DependencyResolver.Current.GetService <IPortfolioDetailsRepository>();
         PortfolioDetail             item       = repository.GetById(entityId);
         if (item != null && f == Field.Name)
         {
             translation.Original = item.Name;
         }
     }
     if (t == Table.Portfolios)
     {
         IPortfoliosRepository repository = DependencyResolver.Current.GetService <IPortfoliosRepository>();
         Portfolio             item       = repository.GetById(entityId);
         if (item != null && f == Field.Name)
         {
             translation.Original = item.Name;
         }
         if (item != null && f == Field.Description)
         {
             translation.Original = item.Description;
         }
     }
     if (t == Table.ProductCategories)
     {
         IProductCategoriesRepository repository = DependencyResolver.Current.GetService <IProductCategoriesRepository>();
         ProductCategory item = repository.GetById(entityId);
         if (item != null && f == Field.Name)
         {
             translation.Original = item.Name;
         }
         if (item != null && f == Field.Description)
         {
             translation.Original = item.Description;
         }
     }
     if (t == Table.Products)
     {
         IProductsRepository repository = DependencyResolver.Current.GetService <IProductsRepository>();
         Product             item       = repository.GetById(entityId);
         if (item != null && f == Field.Name)
         {
             translation.Original = item.Name;
         }
         if (item != null && f == Field.Description)
         {
             translation.Original = item.Description;
         }
     }
     if (t == Table.Quotes)
     {
         IQuotesRepository repository = DependencyResolver.Current.GetService <IQuotesRepository>();
         Quote             item       = repository.GetById(entityId);
         if (item != null && f == Field.Description)
         {
             translation.Original = item.Description;
         }
     }
     if (t == Table.Sliders)
     {
         ISlidersRepository repository = DependencyResolver.Current.GetService <ISlidersRepository>();
         Slider             item       = repository.GetById(entityId);
         if (item != null && f == Field.Name)
         {
             translation.Original = item.Name;
         }
     }
 }