public IHttpActionResult PutMyResume(int id, MyResume myResume) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != myResume.Id) { return(BadRequest()); } db.Entry(myResume).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!MyResumeExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Create([Bind(Include = "Id,Name,Age,Education,nationality,Experience,PhoneNumber,Email")] Submit submit) { if (ModelState.IsValid) { db.SubmitResume.Add(submit); db.SaveChanges(); return(RedirectToAction("Home", "Jobseeker")); } return(View(submit)); }
public ActionResult Create([Bind(Include = "ID,Content")] ResumeContent resumeContent) { if (ModelState.IsValid) { db.ResumeContents.Add(resumeContent); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(resumeContent)); }
public ActionResult <Opportunity> UpdateResume(int id, Resume resume) { if (resume == null || id != resume.Id) { return(new BadRequestResult()); } using (var context = new ResumeContext()) { var existing = GetById(id, context); if (existing == null) { return(NotFound("No resume exists with that ID or you do not have access to it.")); } existing.EmailAddress = resume.EmailAddress; existing.FirstName = resume.FirstName; existing.LastName = resume.LastName; existing.HomePostalCode = resume.HomePostalCode; existing.RequiresRelocation = resume.RequiresRelocation; existing.RequiresRemote = resume.RequiresRemote; existing.RequiresSponsorship = resume.RequiresSponsorship; // TODO: This should also update desired skills, potentially context.SaveChanges(); return(Ok(existing)); } }
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); }
public string Put(LostJobModel editedJob) { string success = ""; try { using (var db = new ResumeContext()) { var job = db.LostJobs.Where(j => j.Id == editedJob.Id).FirstOrDefault(); if (job == null) { success = "record not found"; } else { job.StartMonth = editedJob.StartMonth; job.StartYear = editedJob.StartYear; job.FiredMonth = editedJob.FiredMonth; job.FiredYear = editedJob.FiredYear; job.JobTitle = editedJob.JobTitle; job.Employer = editedJob.Employer; job.JobLocation = editedJob.JobLocation; job.Summary = editedJob.Summary; job.ReasonForLeaving = editedJob.ReasonForLeaving; job.SecretNarative = editedJob.SecretNarative; db.SaveChanges(); success = "ok"; } } } catch (Exception ex) { success = Helpers.ErrorDetails(ex); } return(success); }
public ActionResult <Opportunity> UpdateOpportunity(int id, Opportunity opportunity) { if (opportunity == null || id != opportunity.Id) { return(new BadRequestResult()); } using var context = new ResumeContext(); var existing = GetById(id, context); if (existing == null) { return(NotFound("No opportunity exists with that ID or you do not have access to it.")); } existing.Company = opportunity.Company; existing.JobTitle = opportunity.JobTitle; existing.PostalCode = opportunity.PostalCode; // TODO: This should also update desired skills, potentially context.SaveChanges(); return(Ok(existing)); }
public void Add(Project newProject) { Project project = new Project { Pictures = newProject.Pictures, ProjectDescription = newProject.ProjectDescription, ProjectGitHubLink = newProject.ProjectGitHubLink, ProjectName = newProject.ProjectName, Tags = newProject.Tags }; _context.Add(project); _context.SaveChanges(); }
public ActionResult VacancyCreate(Vacancy newvacancy)//получаем введенные данные по вакансии { //Добавляем вакансию в таблицу db.Vacancies.Add(newvacancy); db.SaveChanges(); // перенаправляем на главную страницу return(RedirectToAction("Index")); }
public ActionResult <Resume> CreateResume(Resume opportunity) { if (opportunity == null) { return(new BadRequestResult()); } using (var context = new ResumeContext()) { var result = context.Resumes.Add(opportunity); context.SaveChanges(); // TODO: This really should return a full URL starting relative to the controller return(Created($"/api/resumes/{result.Entity.Id}", result.Entity)); } }
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 ActionResult <Opportunity> DeleteOpportunity(int id) { using var context = new ResumeContext(); InitOpportunitiesIfNeeded(context); var match = GetById(id, context);; if (match != null) { context.Opportunities.Remove(match); context.SaveChanges(); return(Ok()); } return(NotFound("No opportunity exists with that ID or you do not have access to it.")); }
private static void InitResumesIfNeeded(ResumeContext context) { // Add a sample opportunity if none is present if (!context.Resumes.Any()) { context.Resumes.Add(new Resume { FirstName = "Matt", LastName = "Eland", Educations = new List <Education>(), EmailAddress = "*****@*****.**", HomePostalCode = "50000", RequiresRelocation = true, RequiresRemote = false, RequiresSponsorship = false }); context.SaveChanges(); } }
public IActionResult SendMessage([Bind("FullName,Email,Subject,Msg,Token")] Message message) { var recap = _reCAPTCHAService.Verify(message.Token); if (!recap.Result.success && recap.Result.score <= 0.5) { ModelState.AddModelError(string.Empty, "You are a bot"); return(View(message)); } if (ModelState.IsValid) { message.Status = false; message.SendingDate = DateTime.Now; _context.Add(message); _context.SaveChanges(); return(RedirectToAction(nameof(SendMessage))); } return(View(message)); }
private static void InitOpportunitiesIfNeeded(ResumeContext context) { // Add a sample opportunity if none is present if (!context.Opportunities.Any()) { context.Opportunities.Add(new Opportunity() { Company = "FakeCorp", PostalCode = "43081", JobTitle = "Basket Engineer", DesiredSkills = new List <Skill> { new Skill { ShortName = "Underwater Basket Weaving", Level = SkillLevel.Beginner } } }); context.SaveChanges(); } }
public ActionResult ExternalLoginConfirmation(RegisterExternalLoginModel model, string returnUrl) { string provider = null; string providerUserId = null; if (User.Identity.IsAuthenticated || !OAuthWebSecurity.TryDeserializeProviderUserId(model.ExternalLoginData, out provider, out providerUserId)) { return(RedirectToAction("Manage")); } if (ModelState.IsValid) { // Insert a new user into the database using (ResumeContext db = new ResumeContext()) { UserProfile user = db.UserProfiles.FirstOrDefault(u => u.UserName.ToLower() == model.UserName.ToLower()); // Check if user already exists if (user == null) { // Insert name into the profile table db.UserProfiles.Add(new UserProfile { UserName = model.UserName }); db.SaveChanges(); OAuthWebSecurity.CreateOrUpdateAccount(provider, providerUserId, model.UserName); OAuthWebSecurity.Login(provider, providerUserId, createPersistentCookie: false); return(RedirectToLocal(returnUrl)); } else { ModelState.AddModelError("UserName", "User name already exists. Please enter a different user name."); } } } ViewBag.ProviderDisplayName = OAuthWebSecurity.GetOAuthClientData(provider).DisplayName; ViewBag.ReturnUrl = returnUrl; return(View(model)); }
public string Post(ResumeModel newResume) { string success = "ERROR: "; try { using (var db = new ResumeContext()) { var r = new DataContext.Resume(); r.ResumeName = newResume.ResumeName; r.Created = DateTime.Now; r.PersonId = newResume.PersonId; db.Resumes.Add(r); db.SaveChanges(); success = r.Id.ToString(); } } catch (Exception ex) { success = Helpers.ErrorDetails(ex); } return(success); }
private bool InitializeAdmin() { try { var builder = new ConfigurationBuilder().AddJsonFile("appsettings.json"); IConfiguration AppConfiguration = builder.Build(); IConfigurationSection adminOptions = AppConfiguration.GetSection("Admin"); if (adminOptions != null) { string adminLogin = adminOptions.GetSection("login").Value; string adminPassword = adminOptions.GetSection("password").Value; if (adminLogin == null || adminPassword == null) { _logger.LogError("Fail initialize login or password subsection in appsettings.json"); return(false); } if (_resumeContext.UsrAdmins.ToArray().Length == 0) { var admin = new UsrAdmin() { Login = adminLogin, Password = _authentication.GetHashString(adminPassword) }; _resumeContext.Add(admin); _resumeContext.SaveChanges(); } return(true); } else { _logger.LogError("Fail initialize admin section in appsettings.json"); return(false); } } catch (Exception ex) { _logger.LogError(ex, "Fail initialize admin"); return(false); } }
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); }
public string Delete(ResumeElementModel deleteElement) { string success = ""; try { using (var db = new ResumeContext()) { var element = db.ResumeElements.Where(e => e.ElementId.ToString() == deleteElement.ElementId && e.ResumeId == deleteElement.ResumeId).FirstOrDefault(); if (element == null) { success = "record not found"; } else { db.ResumeElements.Remove(element); db.SaveChanges(); success = "ok"; } } } catch (Exception ex) { success = Helpers.ErrorDetails(ex); } return(success); }
public string Post(ResumeElementModel elementModel) { string success = ""; try { var test = elementModel.ElementId.Replace("'", ""); using (var db = new ResumeContext()) { db.ResumeElements.Add(new ResumeElement() { ElementId = elementModel.ElementId.Replace("'", ""), ElementType = elementModel.ElementType, SortOrder = elementModel.SortOrder, ResumeId = elementModel.ResumeId }); db.SaveChanges(); success = "ok"; } } catch (Exception ex) { success = Helpers.ErrorDetails(ex); } return(success); }
public string Put(ResumeModel resumeModel) { string success = ""; try { using (var db = new ResumeContext()) { DataContext.Resume resume = db.Resumes.Where(r => r.Id == resumeModel.Id).FirstOrDefault(); if (resume != null) { resume.ResumeName = resumeModel.ResumeName; db.SaveChanges(); success = "ok"; } else { success = "Resume not found"; } } } catch (Exception ex) { success = Helpers.ErrorDetails(ex); } return(success); }
public IActionResult CreateSkill([FromBody] Skill skill) { // [FromBody] to indicate where to get the data for model binding _context.Skills.Add(skill); _context.SaveChanges(); return(CreatedAtRoute("GetAllSkills", new { id = skill.ID }, skill)); }
public IActionResult CreateExperience(Experience experience) { _context.Experiences.Add(experience); _context.SaveChanges(); return(CreatedAtRoute("GetAllExperiences", experience)); }
public void Add(Tag newTag) { _contex.Add(newTag); _contex.SaveChanges(); }
public ActionResult CreateResume(Resume resume) { _context.Resumes.Add(resume); _context.SaveChanges(); return(RedirectToAction("Resume", "Home")); }
public void Save() { context.SaveChanges(); }
public IActionResult CreateEducation([FromBody] Education edu) { _context.Education.Add(edu); _context.SaveChanges(); return(CreatedAtRoute("GetAllEducation", new { id = edu.ID }, edu)); }
public IActionResult CreateTask(Task task) { _context.Tasks.Add(task); _context.SaveChanges(); return(CreatedAtRoute("GetAllTasks", task)); }
public IActionResult CreateActivity(Activity act) { _context.Activities.Add(act); _context.SaveChanges(); return(CreatedAtRoute("GetAllActivities", act)); }