コード例 #1
0
        public static PortfolioAJAX GetSerializedObject(tblPortfolio item)
        {
            var returnItem = new PortfolioAJAX()
            {
                Id           = item.ItemId,
                Title        = item.ItemTitle,
                Date         = item.ItemDate.Value.ToShortDateString(),
                Description  = item.ItemDescription,
                Url          = string.Empty,
                ExpandText   = (item.tblExpandText == null) ? string.Empty : item.tblExpandText.ExpandText,
                CodeUrl      = (item.ItemCodeUrl == null) ? string.Empty : item.ItemCodeUrl,
                Languages    = (item.ItemLanguage == null) ? string.Empty : item.ItemLanguage,
                Software     = (item.ItemSoftware == null) ? string.Empty : item.ItemSoftware,
                ThumbImage   = "images/thumbs/" + item.tblSection.SectionFolderName + "/" + item.ItemImageName,
                PreviewImage = "images/preview/" + item.tblSection.SectionFolderName + "/" + item.ItemImageName,
                FullImage    = "images/fullsize/" + item.tblSection.SectionFolderName + "/" + item.ItemImageName,
                SectionId    = item.ItemSectionId.Value.ToString(),
            };

            if (item.ItemWebUrl != null)
            {
                returnItem.Url = item.ItemWebUrl;
                if (!item.ItemWebUrl.Contains("http://") && item.ItemWebUrl != "None")
                {
                    returnItem.Url = "images/fullsize/" + item.tblSection.SectionFolderName + "/" + item.ItemWebUrl;
                }
            }
            return(returnItem);
        }
コード例 #2
0
        public int Update()
        {
            try
            {
                using (PortfolioEntities dc = new PortfolioEntities())
                {
                    tblPortfolio portfolio = dc.tblPortfolios.Where(p => p.Id == Id).FirstOrDefault();
                    if (portfolio != null)
                    {
                        portfolio.Name           = Name;
                        portfolio.Description    = Description;
                        portfolio.PrivacyId      = PrivacyId;
                        portfolio.PortfolioImage = PortfolioImage;
                        portfolio.UserId         = UserId;

                        return(dc.SaveChanges());
                    }
                    else
                    {
                        throw new Exception("Portfolio not found");
                    }
                }
            }
            catch (Exception ex) { throw ex; }
        }
コード例 #3
0
        /// <summary>
        /// Insert project into portfolio
        /// </summary>
        /// <param name="projectId"> Id of Project to add to Portfolio object </param>
        /// <returns> bool for success status </returns>
        public bool AddProject(Guid projectId)
        {
            try
            {
                Project project = new Project();
                project.LoadById(projectId);
                Portfolio   port = new Portfolio();
                ProjectList prjs = new ProjectList();
                prjs = port.LoadProjects(port.Id);
                foreach (Project prj in prjs)
                {
                    if (prj.Name == project.Name)
                    {
                        // Already exists in Portfolio
                        return(false); //this should probably be a throw ex
                    }
                }


                using (PortfolioEntities dc = new PortfolioEntities())
                {
                    tblPortfolio        portfolio = dc.tblPortfolios.Where(p => p.Id == Id).FirstOrDefault();
                    tblPortfolioProject portProj  = new tblPortfolioProject()
                    {
                        Id          = Guid.NewGuid(),
                        ProjectId   = projectId,
                        PortfolioId = portfolio.Id
                    };
                    dc.tblPortfolioProjects.Add(portProj);
                    dc.SaveChanges();
                }
                return(true);
            }
            catch (Exception ex) { throw ex; }
        }
コード例 #4
0
ファイル: utPortfolio.cs プロジェクト: B-Lemke/FVTC_ProveIT
        public void DeleteTest()
        {
            using (PortfolioEntities dc = new PortfolioEntities())
            {
                Guid         portfolioGuid = Guid.Parse("11112222-3333-4444-5555-666677778888");
                tblPortfolio portfolio     = dc.tblPortfolios.FirstOrDefault(p => p.Id == portfolioGuid);

                dc.tblPortfolios.Remove(portfolio);

                dc.SaveChanges();

                tblPortfolio deletedPortfolio = dc.tblPortfolios.FirstOrDefault(p => p.Id == portfolioGuid);

                Assert.IsNull(deletedPortfolio);
            }
        }
コード例 #5
0
ファイル: utPortfolio.cs プロジェクト: B-Lemke/FVTC_ProveIT
        public void UpdateTest()
        {
            using (PortfolioEntities dc = new PortfolioEntities())
            {
                //Retrieve test portfolio based on ID and update it
                Guid portfolioGuid = Guid.Parse("11112222-3333-4444-5555-666677778888");

                tblPortfolio portfolio = dc.tblPortfolios.FirstOrDefault(p => p.Id == portfolioGuid);

                Guid userGuid = Guid.Parse("88887777-6666-5555-4444-333322221111");
                portfolio.UserId = userGuid;

                //Save changes and get it back out
                dc.SaveChanges();
                tblPortfolio updatedPortfolio = dc.tblPortfolios.FirstOrDefault(p => p.UserId == userGuid);
                //Make sure the Ids match
                Assert.AreEqual(portfolio.Id, updatedPortfolio.Id);
            }
        }
コード例 #6
0
 public int Delete()
 {
     try
     {
         using (PortfolioEntities dc = new PortfolioEntities())
         {
             tblPortfolio portfolio = dc.tblPortfolios.Where(p => p.Id == Id).FirstOrDefault();
             if (portfolio != null)
             {
                 dc.tblPortfolios.Remove(portfolio);
                 return(dc.SaveChanges());
             }
             else
             {
                 throw new Exception("Portfolio not found");
             }
         }
     }
     catch (Exception ex) { throw ex; }
 }
コード例 #7
0
        public ActionResult DeletePortfolio(int id)
        {
            if (Session["UserID"] == null && Session["UserName"] == null)
            {
                return(RedirectToAction("Login", "Login"));
            }

            try
            {
                tblPortfolio portfolio = db.tblPortfolios.Find(id);
                string       path      = Server.MapPath("~/PortfolioCoverImage/" + portfolio.CoverPhoto);
                FileInfo     delfile   = new FileInfo(path);
                delfile.Delete();
                db.tblPortfolios.Remove(portfolio);
                db.SaveChanges();
                return(Json(new { success = true, message = "Record deleted successfully" }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { success = false, message = "Error!" + ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #8
0
ファイル: utPortfolio.cs プロジェクト: B-Lemke/FVTC_ProveIT
        public void InsertTest()
        {
            using (PortfolioEntities dc = new PortfolioEntities())
            {
                //Create a portfolio
                tblPortfolio portfolio = new tblPortfolio
                {
                    Id             = Guid.Parse("11112222-3333-4444-5555-666677778888"),
                    Description    = "Test",
                    Name           = "Test",
                    PortfolioImage = "Test",
                    UserId         = Guid.NewGuid()
                };

                //Add the portfolio to the database
                dc.tblPortfolios.Add(portfolio);

                //Commit changes
                int rowsInserted = dc.SaveChanges();

                Assert.IsTrue(rowsInserted == 1);
            }
        }
コード例 #9
0
        public ActionResult ActivateDeactivateFolio()
        {
            if (Session["UserID"] == null && Session["UserName"] == null)
            {
                return(RedirectToAction("Login", "Login"));
            }

            try
            {
                int          id        = Convert.ToInt32(Request.Form["id"]);
                int          Flag      = Convert.ToInt32(Request.Form["flag"]);
                tblPortfolio portfolio = db.tblPortfolios.SingleOrDefault(c => c.PortfolioID == id);

                if (Flag >= 1)
                {
                    portfolio.IsActive = true;
                }
                else
                {
                    portfolio.IsActive = false;
                }
                db.Entry(portfolio).State = EntityState.Modified;
                db.SaveChanges();
                if (Flag >= 1)
                {
                    return(Json(new { Act = true, message = "Portfolio is activated" }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { DeAct = true, message = "Portfolio is de-activated" }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                return(Json(new { Error = false, message = "Error!" + ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #10
0
        public int Insert()
        {
            try
            {
                using (PortfolioEntities dc = new PortfolioEntities())
                {
                    tblPortfolio portfolio = new tblPortfolio()
                    {
                        Id             = Guid.NewGuid(),
                        Name           = Name,
                        Description    = Description,
                        PortfolioImage = PortfolioImage,
                        PrivacyId      = PrivacyId,
                        UserId         = UserId
                    };
                    //Save the Id
                    this.Id = portfolio.Id;

                    dc.tblPortfolios.Add(portfolio);
                    return(dc.SaveChanges());
                }
            }
            catch (Exception ex) { throw ex; }
        }
コード例 #11
0
        public ActionResult InsertPortfolio()
        {
            if (Session["UserID"] == null && Session["UserName"] == null)
            {
                return(RedirectToAction("Login", "Login"));
            }

            try
            {
                if (ModelState.IsValid)
                {
                    tblPortfolio portfolio  = new tblPortfolio();
                    int          CustomerID = Convert.ToInt32(Request.Form["CustomerID"]);

                    if (IsPortfolioExist(CustomerID))
                    {
                        return(Json(new { success = false, message = "Portfolio of selected customer is already exist!" }, JsonRequestBehavior.AllowGet));
                    }

                    portfolio.CustomerID           = CustomerID;
                    portfolio.PortfolioHeading     = Request.Form["Heading"];
                    portfolio.PortfolioDescription = Request.Form["Description"];
                    portfolio.IsActive             = Request.Form["IsActive"] == "true" ? true : false;
                    portfolio.CreatedDate          = DateTime.Now;

                    if (ModelState.IsValid)
                    {
                        int              fileSize = 0;
                        string           fileName = string.Empty;
                        string           mimeType = string.Empty;
                        System.IO.Stream fileContent;

                        if (Request.Files.Count > 0)
                        {
                            HttpPostedFileBase file = Request.Files[0];

                            fileSize    = file.ContentLength;
                            fileName    = file.FileName;
                            mimeType    = file.ContentType;
                            fileContent = file.InputStream;


                            if (mimeType.ToLower() != "image/jpeg" && mimeType.ToLower() != "image/jpg" && mimeType.ToLower() != "image/png")
                            {
                                return(Json(new { Formatwarning = true, message = "Profile pic format must be JPEG or JPG or PNG." }, JsonRequestBehavior.AllowGet));
                            }

                            #region Save And compress file
                            //To save file, use SaveAs method
                            file.SaveAs(Server.MapPath("~/PortfolioCoverImage/") + fileName);
                            if (!ImageProcessing.InsertImages(Server.MapPath("~/PortfolioCoverImage/") + fileName))
                            {
                                return(Json(new { success = false, message = "Error occur while uploading image." }, JsonRequestBehavior.AllowGet));
                            }
                            #endregion
                        }
                        portfolio.CoverPhoto = fileName;
                    }
                    db.tblPortfolios.Add(portfolio);
                    db.SaveChanges();
                }
                return(Json(new { success = true, message = "Record inserted" }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { success = false, message = "Error!" + ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }