public List <ProfessionalSkill> GetAllProfessionalSkills(int userId) { var connection = new SqlConnection(connectionString); var query = "SELECT * FROM ProfessionalSkills WHERE UserId=@UserId"; var command = new SqlCommand(query, connection); command.Parameters.Clear(); command.Parameters.Add("@UserId", SqlDbType.Int); command.Parameters["@UserId"].Value = userId; connection.Open(); var reader = command.ExecuteReader(); List <ProfessionalSkill> professionalSkillsList = new List <ProfessionalSkill>(); while (reader.Read()) { ProfessionalSkill professionalSkills = new ProfessionalSkill { Id = Convert.ToInt32(reader["Id"]), Skill = Convert.ToString(reader["Skill"]), UserId = Convert.ToInt32(reader["UserId"]) }; professionalSkillsList.Add(professionalSkills); } reader.Close(); connection.Close(); return(professionalSkillsList); }
// GET: ProfessionalSkill/Create public ActionResult Create(int id) { var skill = new ProfessionalSkill(); skill.PersonId = id; return(View(skill)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,SkillDescrption,Date,InstitutionName,State,City,ZipCode")] ProfessionalSkill professionalSkill) { if (id != professionalSkill.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(professionalSkill); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProfessionalSkillExists(professionalSkill.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(professionalSkill)); }
public ProfessionalSkill GetProfessionalSkill(int professionalSkillId) { var connection = new SqlConnection(connectionString); var query = "SELECT * FROM ProfessionalSkills WHERE Id=@Id"; var command = new SqlCommand(query, connection); command.Parameters.Clear(); command.Parameters.Add("@Id", SqlDbType.Int); command.Parameters["@Id"].Value = professionalSkillId; connection.Open(); var reader = command.ExecuteReader(); ProfessionalSkill professionalSkill = null; if (reader.Read()) { professionalSkill = new ProfessionalSkill { Id = Convert.ToInt32(reader["Id"]), Skill = Convert.ToString(reader["Skill"]), UserId = Convert.ToInt32(reader["UserId"]) }; } reader.Close(); connection.Close(); return(professionalSkill); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Subject,Details,UserId,IsPublic")] ProfessionalSkill professionalSkill) { if (id != professionalSkill.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(professionalSkill); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProfessionalSkillExists(professionalSkill.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("ProfetionalSkill", "UserProfile")); } ViewData["UserId"] = new SelectList(_context.Users, "Id", "Id", professionalSkill.UserId); return(View(professionalSkill)); }
public ActionResult Edit(ProfessionalSkill skill) { if (ModelState.IsValid) { _unitOfWork.ProfessionalSkillRepository.Edit(skill); return(RedirectToAction("FullInformation", "Home", new { id = skill.PersonId })); } return(View(skill)); }
public async Task <IActionResult> Create([Bind("ID,SkillDescrption,Date,InstitutionName,State,City,ZipCode")] ProfessionalSkill professionalSkill) { if (ModelState.IsValid) { _context.Add(professionalSkill); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(professionalSkill)); }
public async Task <IActionResult> Create([Bind("Id,Subject,Details,UserId,IsPublic")] ProfessionalSkill professionalSkill) { if (ModelState.IsValid) { _context.Add(professionalSkill); await _context.SaveChangesAsync(); return(RedirectToAction("ProfetionalSkill", "UserProfile")); } ViewData["UserId"] = new SelectList(_context.Users, "Id", "Id", professionalSkill.UserId); return(View(professionalSkill)); }
public int UpdateProfessionalSkill(ProfessionalSkill professionalSkill) { var connection = new SqlConnection(connectionString); var query = "UPDATE ProfessionalSkills SET Skill=@Skill WHERE Id=@Id"; var command = new SqlCommand(query, connection); command.Parameters.Clear(); command.Parameters.Add("@Skill", SqlDbType.VarChar); command.Parameters["@Skill"].Value = professionalSkill.Skill; command.Parameters.Add("@UserId", SqlDbType.Int); command.Parameters["@UserId"].Value = professionalSkill.UserId; connection.Open(); int rowsAffected = command.ExecuteNonQuery(); connection.Close(); return(rowsAffected); }
public int AddProfessionalSkill(ProfessionalSkill professionalSkill) { var connection = new SqlConnection(connectionString); var query = "SP_AddProfessionalSkill"; var command = new SqlCommand(query, connection) { CommandType = CommandType.StoredProcedure }; command.Parameters.Clear(); command.Parameters.Add("@Skill", SqlDbType.VarChar); command.Parameters["@Skill"].Value = professionalSkill.Skill; command.Parameters.Add("@UserId", SqlDbType.Int); command.Parameters["@UserId"].Value = professionalSkill.UserId; connection.Open(); int professionalSkillId = Convert.ToInt32(command.ExecuteScalar()); connection.Close(); return(professionalSkillId); }
public int UpdateProfessionalSkill(ProfessionalSkill professionalSkill) { return(_basicInfoGateway.UpdateProfessionalSkill(professionalSkill)); }
public int AddProfessionalSkill(ProfessionalSkill professionalSkill) { return(_basicInfoGateway.AddProfessionalSkill(professionalSkill)); }