예제 #1
0
        public string Put(ResumeSectionModel editedSection)
        {
            string success = "";

            try
            {
                using (var db = new ResumeContext())
                {
                    var Section = db.ResumeSections.Where(j => j.Id == editedSection.Id).FirstOrDefault();
                    if (Section == null)
                    {
                        success = "record not found";
                    }
                    else
                    {
                        //Section.SectionType = editedSection.SectionType;
                        Section.SectionTitle    = editedSection.SectionTitle;
                        Section.SectionContents = editedSection.SectionContents;

                        db.SaveChanges();
                        success = "ok";
                    }
                }
            }
            catch (Exception ex) { success = Helpers.ErrorDetails(ex); }
            return(success);
        }
예제 #2
0
 private ResumeModel GetResumeModel(long id)
 {
     try
     {
         ResumeModel resumeModel = new ResumeModel();
         Resume      resume      = db.Resumes.Where(x => x.id == id).SingleOrDefault();
         if (resume != null)
         {
             resumeModel.background = resume.background;
             resumeModel.header     = resume.header;
             List <ResumeSection> resumeSections = db.ResumeSections.Where(x => x.resumeID == id).ToList();
             if (resumeSections != null)
             {
                 resumeModel.resumeSections = new List <ResumeSectionModel>();
                 foreach (ResumeSection resumeSection in resumeSections)
                 {
                     ResumeSectionModel resumeSectionModel = new ResumeSectionModel();
                     resumeSectionModel.header = resumeSection.header;
                     List <ResumeSectionItem> resumeSectionsItems =
                         db.ResumeSectionItems.Where(x => x.resumeSectionID == resumeSection.id).ToList();
                     if (resumeSectionsItems != null)
                     {
                         List <ResumeSubSectionModel> resumeSubSectionModels = new List <ResumeSubSectionModel>();
                         foreach (ResumeSectionItem resumeSectionItem in resumeSectionsItems)
                         {
                             ResumeSubSectionModel resumeSubSectionModel = new ResumeSubSectionModel();
                             resumeSubSectionModel.date        = resumeSectionItem.date;
                             resumeSubSectionModel.location    = resumeSectionItem.location;
                             resumeSubSectionModel.header      = resumeSectionItem.header;
                             resumeSubSectionModel.explanation = resumeSectionItem.explanation;
                             List <ResumeSectionItemExplanation> resumeSectionItemExplanations =
                                 db.ResumeSectionItemExplanations.Where(x => x.resumeSectionItemID == resumeSectionItem.id).ToList();
                             if (resumeSectionItemExplanations != null)
                             {
                                 List <string> items = new List <string>();
                                 foreach (ResumeSectionItemExplanation resumeSectionItemExplanation in resumeSectionItemExplanations)
                                 {
                                     items.Add(resumeSectionItemExplanation.explanation);
                                     resumeSubSectionModel.explanationItems = items;
                                 }
                             }
                             resumeSubSectionModels.Add(resumeSubSectionModel);
                             resumeSectionModel.resumeSubSections = resumeSubSectionModels;
                         }
                     }
                     resumeModel.resumeSections.Add(resumeSectionModel);
                 }
             }
         }
         return(resumeModel);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(null);
     }
 }
예제 #3
0
        public ResumeSectionModel Get(string sectionId)
        {
            var section = new ResumeSectionModel();

            try
            {
                using (var db = new ResumeContext())
                {
                    var dbSection = db.ResumeSections.Where(s => s.Id == sectionId).FirstOrDefault();
                    if (dbSection != null)
                    {
                        section.Id              = sectionId;
                        section.PersonId        = dbSection.PersonId;
                        section.SectionTitle    = dbSection.SectionTitle;
                        section.SectionContents = dbSection.SectionContents;
                    }
                }
            }
            catch (Exception ex) { section.SectionTitle = Helpers.ErrorDetails(ex); }
            return(section);
        }
예제 #4
0
        public string Post(ResumeSectionModel newSection)
        {
            string success = "ERROR: ";

            try
            {
                ResumeSection section = new ResumeSection();
                section.Id           = Guid.NewGuid().ToString();
                section.PersonId     = newSection.PersonId;
                section.SectionTitle = newSection.SectionTitle;
                //section.SectionType = "";
                section.SectionContents = newSection.SectionContents;
                using (var db = new ResumeContext())
                {
                    db.ResumeSections.Add(section);
                    db.SaveChanges();
                    success = section.Id.ToString();
                }
            }
            catch (Exception ex) { success += Helpers.ErrorDetails(ex); }
            return(success);
        }
예제 #5
0
 public static ResumeSection ToEntity(this ResumeSectionModel model, ResumeSection destination)
 {
     return(model.MapTo(destination));
 }
예제 #6
0
 public static ResumeSection ToEntity(this ResumeSectionModel model)
 {
     return(model.MapTo <ResumeSectionModel, ResumeSection>());
 }