Exemple #1
0
        public bool UpsertMemberToDo(MemberToDoModel todo)
        {
            const string logMethodName = " -UpsertMemberToDo(string memberId)";

            Log.Debug(logMethodName + "Begin Method");
            if (ModelValidation <MemberToDoModel> .validateModel(todo))
            {
                if (_asaMemberAdapter.IsCurrentUser(todo.MemberID.ToString()))
                {
                    try
                    {
                        bool status = _asaMemberAdapter.UpsertMemberToDo(todo);
                        Log.Debug(logMethodName + "End Method");
                        return(status);
                    }
                    catch (Exception ex)
                    {
                        Log.Error(logMethodName + ": Raised an exception executing your request +> ", ex);
                        throw new Exception("Exception from UpsertMemberToDo: ", ex);
                    }
                }
                else
                {
                    throw new WebFaultException <string>("Not Authorized", System.Net.HttpStatusCode.Unauthorized);
                }
            }
            return(false);
        }
Exemple #2
0
 public static MemberToDoListContract ToDataContract(this MemberToDoModel todo)
 {
     return(new MemberToDoListContract()
     {
         MemberToDoListID = todo.MemberToDoListID,
         MemberID = todo.MemberID,
         ContentID = todo.ContentID,
         RefToDoStatusID = todo.RefToDoStatusID,
         RefToDoTypeID = todo.RefToDoTypeID,
         CreatedBy = todo.CreatedBy,
         CreatedDate = todo.CreatedDate,
         ModifiedDate = todo.ModifiedDate,
         ModifiedBy = todo.ModifiedBy
     });
 }
Exemple #3
0
        public bool UpsertMemberToDo(MemberToDoModel todo)
        {
            bool result;

            try
            {
                result = SaltServiceAgent.UpsertMemberToDo(todo.ToDataContract());
            }
            catch (Exception ex)
            {
                Log.Error("UpsertMemberToDo Exception =>", ex);
                throw;
            }
            return(result);
        }
Exemple #4
0
        /// <summary>
        /// Syncs Courses ToDo completion status from Moodle asynchronously
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public bool SyncCoursesCompletion(int userId)
        {
            String logMethodName = "- SyncCoursesCompletion(int userId) :";

            Log.Debug(logMethodName + "Begin Method");
            //Sync courses completion asynchronously
            Task.Factory.StartNew(() =>
            {
                Log.Debug(logMethodName + "Execute Method Asynchronous - Begin Method");
                bool syncHappened = false;

                List <OrganizationProductModel> orgProducts = GetMemberOrganizationProducts(userId);

                //if not subscibed to courses product no need to sync, just return false
                if (!isSubscribedToProduct(orgProducts, 2))
                {
                    return(syncHappened);
                }

                //get courses status from moodle
                var memberCourses     = GetMemberCourses(userId, true);
                var completedCourses  = memberCourses.Where(course => course.CompleteStatus).ToList();
                var coursesContentIds = new List <string>();
                foreach (var course in memberCourses)
                {
                    coursesContentIds.Add(course.ContentID);
                }

                //get membertodos from salt db
                var memberTodos = GetMemberToDos(userId).ToList();
                //filter member todos taking only courses
                var memberCoursesTodos   = memberTodos.Where(item => coursesContentIds.Contains(item.ContentID)).ToList();
                bool courseAlreadySynced = false;
                //compare course todo list against moodle completion
                foreach (var course in completedCourses)
                {
                    foreach (var courseTodo in memberCoursesTodos)
                    {
                        if (courseTodo.ContentID == course.ContentID && courseTodo.RefToDoStatusID == 2)
                        {
                            courseAlreadySynced = true;
                            break;
                        }
                    }
                    if (!courseAlreadySynced)
                    {
                        //Sync todo status from mooodle
                        MemberToDoModel courseTodo = new MemberToDoModel()
                        {
                            MemberID        = userId,
                            ContentID       = course.ContentID,
                            RefToDoTypeID   = 1,
                            RefToDoStatusID = 2 //Complete
                        };

                        UpsertMemberToDo(courseTodo);
                        syncHappened = true;     //there was at least one course synced during this run
                    }
                    courseAlreadySynced = false; //reset sync flag for next course check
                }
                Log.Debug(logMethodName + "Execute Method Asynchronous - End Method");
                return(syncHappened);
            });
            Log.Debug(logMethodName + "End Method");
            return(true);
        }
Exemple #5
0
 public bool UpsertMemberToDo(MemberToDoModel todo)
 {
     throw new NotImplementedException();
 }