private static CourseEnrollment ConstructCourseEnrollmentEmployee(Enrollments selectedEnrollments)
        {
            try
            {
                var Course = new CourseEnrollment()
                {
                    Id            = selectedEnrollments.Id,
                    CourseId      = selectedEnrollments.CourseId,
                    Progress      = selectedEnrollments.Progress,
                    Score         = selectedEnrollments.Score,
                    Status        = Status.Complete,
                    DateCompleted = String.Format("{0:s}", selectedEnrollments.DateCompleted),
                    DateExpires   = String.Format("{0:s}", selectedEnrollments.DateExpires),
                    TimeSpent     = selectedEnrollments.TimeSpent,
                    DateStarted   = selectedEnrollments.DateStarted,
                    Credits       = selectedEnrollments.Credits
                };

                return(Course);
            }
            catch
            {
                throw;
            }
        }
        private static CourseEnrollment ConstructCourseEnrollmentEmployee(Guid enrollmentId, Guid courseId, decimal?progress, decimal?score, DateTime?dateCompleted, DateTime?dateExpires, TimeSpan timeSpent, DateTime?dateStarted, decimal?credits)
        {
            try
            {
                var Course = new CourseEnrollment()
                {
                    Id            = enrollmentId,
                    CourseId      = courseId,
                    Progress      = progress,
                    Score         = score,
                    Status        = Status.Complete,
                    DateCompleted = String.Format("{0:s}", dateCompleted),
                    DateExpires   = String.Format("{0:s}", dateExpires),
                    TimeSpent     = timeSpent,
                    DateStarted   = dateStarted,
                    Credits       = credits
                };

                return(Course);
            }
            catch
            {
                throw;
            }
        }
        public static string UpdateEnrollmentCourse(string token, Guid UserId, CourseEnrollment CourseEnrollmentEmployee)
        {
            string jsonString;

            try
            {
                string UrlDomain = ConfigurationManager.AppSettings["AbsorbUrlDomain"];
                string Url       = UrlDomain + "users/" + UserId + "/enrollments";

                HttpWebRequest request = WebRequest.Create(Url) as HttpWebRequest;
                request.Method      = "POST";
                request.ContentType = " text/json";
                request.Headers.Add("Authorization", token);
                request.UserAgent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
                request.Timeout   = 30000; // 30 seconds

                var javaScriptSerializer = new JavaScriptSerializer();
                jsonString = javaScriptSerializer.Serialize(CourseEnrollmentEmployee);

                using (var streamWriter = new StreamWriter(request.GetRequestStream()))
                {
                    streamWriter.Write(jsonString);
                    streamWriter.Flush();
                }

                // Get response
                //HttpWebResponse myWebResponse = (HttpWebResponse)request.GetResponse();
                HttpWebResponse myWebResponse = GetResponse(request);

                // Get the response stream
                using (StreamReader reader = new StreamReader(myWebResponse.GetResponseStream()))
                {
                    jsonString = reader.ReadToEnd();
                };
            }
            catch (Exception e)
            {
                Carollo.WriteToLog("Error at AbsorbAPI.UpdateEnrollmentCourse: " + e.Message + Environment.NewLine + e.InnerException + Environment.NewLine + e.StackTrace, MessageType.Text, "System", ActionType.WriteToLogError.ToString(), true, DateTime.Now, "");
                throw;
            }

            return(jsonString);
        }