Beispiel #1
0
        //public

        public void UploadPortfolio(PortfolioBindingModel model, string Creator, string imageLocation)
        {
            try
            {
                PortfolioDataModel dataModel = new PortfolioDataModel
                {
                    ImageLocation       = imageLocation,
                    FirstName           = model.FirstName,
                    LastName            = model.LastName,
                    PhoneNumber         = model.PhoneNumber,
                    Email               = Creator,
                    Age                 = model.Age,
                    EducationHighSchool = model.EducationHighSchool,
                    EducationCollege    = model.EducationCollege,
                    Experience          = model.Experience,
                    ExperienceYears     = model.ExperienceYears,
                    AboutMe             = model.AboutMe,
                    Services            = model.Services,
                    Facebook            = model.FacebookAccount,
                    Twitter             = model.TwitterAccount,
                    CVLocation          = ""
                };
                using (var context = new PortfolioDatabase())
                {
                    if (context.Portfolio_table != null)
                    {
                        if (context.Portfolio_table
                            .FirstOrDefault(u => u.Email == Creator) == null)
                        {
                            context.Portfolio_table.Add(dataModel);
                            context.SaveChanges();
                        }
                    }
                    else
                    {
                        context.Portfolio_table.Add(dataModel);
                        context.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #2
0
 public void DeletePortfolio(int?id)
 {
     if (id > -1)
     {
         using (var context = new PortfolioDatabase())
         {
             var result = context.Portfolio_table.FirstOrDefault(p => p.Id == id);
             if (result != null)
             {
                 System.IO.File.Delete(result.ImageLocation);
                 context.Portfolio_table.Remove(result);
                 context.SaveChanges();
             }
         }
     }
 }
Beispiel #3
0
        public void UpdatePortfolio(PortfolioBindingModel model, string Creator, string ImageLocation)
        {
            try
            {
                PortfolioDataModel dataModel = new PortfolioDataModel
                {
                    ImageLocation       = ImageLocation,
                    FirstName           = model.FirstName,
                    LastName            = model.LastName,
                    PhoneNumber         = model.PhoneNumber,
                    Email               = Creator,
                    Age                 = model.Age,
                    EducationHighSchool = model.EducationHighSchool,
                    EducationCollege    = model.EducationCollege,
                    Experience          = model.Experience,
                    ExperienceYears     = model.ExperienceYears,
                    AboutMe             = model.AboutMe,
                    Services            = model.Services,
                    Facebook            = model.FacebookAccount,
                    Twitter             = model.TwitterAccount,
                    CVLocation          = ""
                };
                using (var context = new PortfolioDatabase())
                {
                    var result = context.Portfolio_table.FirstOrDefault(p => p.Email == Creator);

                    if (ImageLocation == "")
                    {
                        dataModel.ImageLocation = result.ImageLocation;
                    }

                    context.Portfolio_table.Remove(result);
                    context.Portfolio_table.Add(dataModel);
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }