Beispiel #1
0
        public IActionResult AddCareer(CareerExperience exp)
        {
            var           usrmgr    = GetUserManager();
            IActionResult result    = GetAuthenticatedView("NewCareer", exp);
            var           profileId = _db.GetProfile(usrmgr.User.Id, true).Id;

            exp.ProfileId = profileId;
            if (ModelState.IsValid)
            {
                try
                {
                    _db.UpdateCareerExperience(exp);
                    result = RedirectToAction("ProfileEdit");
                }
                catch (Exception)
                {
                    try
                    {
                        _db.AddCareer(exp);
                        result = RedirectToAction("ProfileEdit");
                    }
                    catch
                    {
                    }
                }
            }

            return(result);
        }
Beispiel #2
0
        public void UpdateCareerExperience(CareerExperience careerExperience)
        {
            using (SqlConnection conn = new SqlConnection(_connectionString))
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand("UPDATE CareerExperience SET " +
                                                "Title = @Title, " +
                                                "Employer = @Employer, " +
                                                "Industry = @Industry, " +
                                                "StartDate = @StartDate, " +
                                                "EndDate = @EndDate, " +
                                                "JobDescription = @JobDescription " +
                                                "WHERE Id = @Id", conn);

                cmd.Parameters.AddWithValue("@Title", careerExperience.Title);
                cmd.Parameters.AddWithValue("@Employer", careerExperience.Employer);
                cmd.Parameters.AddWithValue("@Industry", careerExperience.Industry);
                cmd.Parameters.AddWithValue("@StartDate", careerExperience.StartDate);
                cmd.Parameters.AddWithValue("@EndDate", careerExperience.EndDate);
                cmd.Parameters.AddWithValue("@JobDescription", careerExperience.JobDescription);
                cmd.Parameters.AddWithValue("@Id", careerExperience.Id);
                int rows = cmd.ExecuteNonQuery();
                if (rows == 0)
                {
                    throw new Exception("exception");
                }
            }
        }
Beispiel #3
0
        public IActionResult AddCareer()
        {
            var usrMgr = GetUserManager();

            ViewData["currentUser"] = usrMgr.User;

            CareerExperience exp = new CareerExperience();

            return(GetAuthenticatedView("NewCareer", exp));
        }
Beispiel #4
0
        public CareerExperience GetCareerExperience(int id)
        {
            CareerExperience career = new CareerExperience();

            using (SqlConnection conn = new SqlConnection(_connectionString))
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand("Select * FROM CareerExperience WHERE Id = @Id;", conn);
                cmd.Parameters.AddWithValue("@Id", id);
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    career = MapRowToCareerExperience(reader);
                }
            }
            return(career);
        }
Beispiel #5
0
        public int AddCareer(CareerExperience exp)
        {
            int id = 0;

            using (SqlConnection conn = new SqlConnection(_connectionString))
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand("INSERT INTO CareerExperience (ProfileId, Title, Employer, Industry, StartDate, EndDate, JobDescription)" +
                                                "VALUES (@ProfileId, @Title, @Employer, @Industry, @StartDate, @EndDate, @JobDescription);" + SCOPE_IDENTITY_SQL, conn);
                cmd.Parameters.AddWithValue("@ProfileId", exp.ProfileId);
                cmd.Parameters.AddWithValue("@Title", exp.Title);
                cmd.Parameters.AddWithValue("@Employer", exp.Employer);
                cmd.Parameters.AddWithValue("@Industry", exp.Industry);
                cmd.Parameters.AddWithValue("@StartDate", exp.StartDate);
                cmd.Parameters.AddWithValue("@EndDate", exp.EndDate);
                cmd.Parameters.AddWithValue("@JobDescription", exp.JobDescription);
                id = (int)cmd.ExecuteScalar();
            }
            return(id);
        }