public string Post(LostJob newJob) { string success = ""; try { using (var db = new ResumeContext()) { newJob.Id = Guid.NewGuid().ToString(); db.LostJobs.Add(newJob); db.SaveChanges(); success = newJob.Id.ToString(); } } catch (Exception ex) { success = Helpers.ErrorDetails(ex); } return(success); }
public List <ResumeElementModel> Get(string resumeId) { var resumeElements = new List <ResumeElementModel>(); using (var db = new ResumeContext()) { var dbElements = db.ResumeElements.Where(e => e.ResumeId == resumeId).ToList(); foreach (ResumeElement element in dbElements) { var m = new ResumeElementModel(); if (element.ElementType == "2") { LostJob lostJob = db.LostJobs.Where(j => j.Id == element.ElementId).FirstOrDefault(); if (lostJob != null) { m.ElementName = lostJob.Employer; } else { m.ElementName = "??"; } } else { ResumeSection x = db.ResumeSections.Where(s => s.Id == element.ElementId).FirstOrDefault(); if (x != null) { m.ElementName = x.SectionTitle; } else { m.ElementName = "?"; } } m.ElementId = element.ElementId.ToString(); m.ElementType = element.ElementType; m.SortOrder = element.SortOrder; resumeElements.Add(m); } } return(resumeElements.OrderBy(r => r.ElementType).ThenBy(r => r.SortOrder).ToList()); }