コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,VolunteerOrganization, VolunteerStartDate, VolunteerEndDate, VolunteerDuties")] VolunteerExperience volunteerExperience)
        {
            if (id != volunteerExperience.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(volunteerExperience);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!VolunteerExperienceExists(volunteerExperience.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(volunteerExperience));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("ID,VolunteerOrganization, VolunteerStartDate, VolunteerEndDate, VolunteerDuties")] VolunteerExperience volunteerExperience)
        {
            if (ModelState.IsValid)
            {
                _context.Add(volunteerExperience);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(volunteerExperience));
        }
コード例 #3
0
        public ActionResult GetResumeAsMarkup(int id)
        {
            //var xml = GlobalConfiguration.Configuration.Formatters.XmlFormatter;
            //var dcs = new DataContractSerializer(typeof(Resume), null, int.MaxValue,
            //    false, /* preserveObjectReferences: */ true, null);
            repository._context.Configuration.ProxyCreationEnabled = false;
            var item = repository._context.Resumes
                       .Include(x => x.UserProfile)
                       .Include(x => x.UserProfile.Country)
                       .Include(x => x.ResumeAchievements)
                       .Include(x => x.ResumeEducations)
                       .Include(x => x.ResumeSkills)
                       .Include(x => x.ResumeSocialNetworks)
                       .Include(x => x.ResumeVolunteerExperiences)
                       .AsNoTracking()
                       .FirstOrDefault(x => x.ID == id); //repository.Resume_Get(id);

            foreach (ResumeAchievement x in item.ResumeAchievements)
            {
                Achievement aTmp = repository.Achievement_Get(x.AchievementID);

                item.Achievements.Add(aTmp);
            }

            foreach (ResumeSkill x in item.ResumeSkills)
            {
                Skill aTmp = repository.Skills_Get(x.SkillID);

                item.Skills.Add(aTmp);
            }

            item.Companies = (from company in item.Skills
                              group company by new { company.Company.ID,
                                                     company.Company.Name,
                                                     company.Company.JobTitle,
                                                     company.Company.DateStart,
                                                     company.Company.DateEnd,
                                                     company.Company.URL,
                                                     company.Company.Summary }
                              into gCompanies
                              select new Company
            {
                ID = gCompanies.Key.ID,
                Name = gCompanies.Key.Name,
                JobTitle = gCompanies.Key.JobTitle,
                DateStart = gCompanies.Key.DateStart,
                DateEnd = gCompanies.Key.DateEnd,
                Summary = gCompanies.Key.Summary,
                URL = gCompanies.Key.URL,
                Skills = item.Skills.Where(x => x.Company.ID == gCompanies.Key.ID).ToList()
            }).ToList();

            foreach (ResumeEducation x in item.ResumeEducations)
            {
                Education aTmp = repository.Educations_Get(x.EducationID);

                item.Educations.Add(aTmp);
            }

            foreach (ResumeVolunteerExperience x in item.ResumeVolunteerExperiences)
            {
                VolunteerExperience aTmp = repository.VolunteerExperience_Get(x.VolunteerExperienceID);

                item.VolunteerExperiences.Add(aTmp);
            }

            foreach (ResumeSocialNetwork x in item.ResumeSocialNetworks)
            {
                UserSocialNetwork aTmp = repository.UserSocialNetwork_Get(x.UserSocialNetworkID);

                item.UserSocialNetworks.Add(aTmp);
            }

            //var serializer = new DataContractSerializer(typeof(Resume));
            //var obj = item;
            //StringBuilder sb = new StringBuilder();
            //using (XmlWriter xw = XmlWriter.Create(sb) /*String.Format("{0}\\test.xml", Server.MapPath("/Content")))*/)
            //{
            //    serializer.WriteObject(xw, obj);
            //    xw.Close();
            //}

            using (System.IO.StreamWriter fs = new System.IO.StreamWriter(String.Format("{0}\\test.xml", Server.MapPath("/Content"))))
            {
                fs.Write(item.ToXMLString());
                fs.Close();
            }

            using (System.IO.StreamWriter fs = new System.IO.StreamWriter(String.Format("{0}\\test.html", Server.MapPath("/Content"))))
            {
                fs.Write(item.ToHTMLString(Server.MapPath("~/Content/Resume.xslt")));
                fs.Close();
            }

            return(View());
        }