Beispiel #1
0
 public void AddUserSkillMapping(int skillId, int userId, int addedByUser)
 {
     try
     {
         using (var context = new TrainingTrackerEntities())
         {
             var skillMapping =
                 context.UserSkillMappings.SingleOrDefault(x => x.SkillId == skillId && x.UserId == userId);
             if (skillMapping == null)
             {
                 return;
             }
             context.UserSkillMappings.Add(new UserSkillMapping
             {
                 SkillId = skillId,
                 AddedBy = addedByUser,
                 UserId  = userId,
                 AddedOn = DateTime.Now
             });
             context.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         LogUtility.ErrorRoutine(ex);
     }
 }
Beispiel #2
0
        public bool AddSubtopicContent(SubtopicContent dataToAdd, out int id)
        {
            try
            {
                using (var context = new TrainingTrackerEntities())
                {
                    EntityFramework.SubtopicContent entityToAdd = new EntityFramework.SubtopicContent
                    {
                        Name             = dataToAdd.Name,
                        Description      = dataToAdd.Description,
                        CourseSubtopicId = dataToAdd.CourseSubtopicId,
                        Url       = dataToAdd.Url,
                        SortOrder = context.SubtopicContents.Where(s => s.CourseSubtopicId == dataToAdd.CourseSubtopicId).Count() + 1,
                        AddedBy   = dataToAdd.AddedBy,
                        CreatedOn = dataToAdd.CreatedOn,
                        IsActive  = dataToAdd.IsActive
                    };
                    context.SubtopicContents.Add(entityToAdd);
                    context.SaveChanges();

                    id = entityToAdd.Id;
                    return(true);
                }
            }
            catch (Exception ex)
            {
                LogUtility.ErrorRoutine(ex);
                id = 0;
                return(false);
            }
        }
Beispiel #3
0
 public bool AddQuestionMapping(List <QuestionLevelMapping> mappings, int questionId)
 {
     try
     {
         using (var context = new TrainingTrackerEntities())
         {
             foreach (var questionLevelMapping in mappings)
             {
                 context.QuestionLevelMappings.Add(new EntityFramework.QuestionLevelMapping
                 {
                     QuestionId           = questionId,
                     Level                = questionLevelMapping.Level,
                     ExperienceStartRange = questionLevelMapping.ExperienceStartRange,
                     ExperienceEndRange   = questionLevelMapping.ExperienceEndRange
                 });
             }
             context.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         LogUtility.ErrorRoutine(ex);
         return(false);
     }
 }
Beispiel #4
0
        public bool UpdateSubtopicContent(SubtopicContent dataToUpdate)
        {
            try
            {
                using (var context = new TrainingTrackerEntities())
                {
                    var entityToUpdate = context.SubtopicContents.Find(dataToUpdate.Id);
                    if (entityToUpdate == null)
                    {
                        return(false);
                    }

                    entityToUpdate.Name             = dataToUpdate.Name;
                    entityToUpdate.Description      = dataToUpdate.Description;
                    entityToUpdate.Url              = dataToUpdate.Url;
                    entityToUpdate.CourseSubtopicId = dataToUpdate.CourseSubtopicId;

                    context.SaveChanges();
                    return(true);
                }
            }
            catch (Exception ex)
            {
                LogUtility.ErrorRoutine(ex);
                return(false);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Delete Learning Map data by making its IsDeleted attribute to true.
        /// </summary>
        /// <param name="id">Learning Map Id whose data is to be deleted</param>
        /// <returns>true if Learning Map data is deleted successfully and false if data to be deleted is not found or some other exception occurs.</returns>
        public bool DeleteLearningMap(int id)
        {
            try
            {
                using (var context = new TrainingTrackerEntities())
                {
                    var learningMapEntity = context.LearningMaps.First(x => x.Id == id);

                    if (learningMapEntity == null)
                    {
                        return(false);
                    }

                    learningMapEntity.IsDeleted = true;
                    context.SaveChanges();

                    return(true);
                }
            }
            catch (Exception ex)
            {
                LogUtility.ErrorRoutine(ex);
                return(false);
            }
        }
Beispiel #6
0
        public bool UpdateCourse(Course courseToUpdate)
        {
            try
            {
                using (var context = new TrainingTrackerEntities())
                {
                    var courseEntity = context.Courses.FirstOrDefault(x => x.Id == courseToUpdate.Id);

                    if (courseEntity == null)
                    {
                        return(false);
                    }

                    courseEntity.Name        = courseToUpdate.Name;
                    courseEntity.Description = courseToUpdate.Description;
                    courseEntity.Icon        = courseToUpdate.Icon;
                    courseEntity.Duration    = courseToUpdate.Duration;
                    context.SaveChanges();

                    return(true);
                }
            }
            catch (Exception ex)
            {
                LogUtility.ErrorRoutine(ex);
                return(false);
            }
        }
Beispiel #7
0
        public bool SaveSubtopicContentProgress(int subtopicContentId, int userId)
        {
            try
            {
                using (var context = new TrainingTrackerEntities())
                {
                    var newEntity = new EntityFramework.SubtopicContentUserMap
                    {
                        SubtopicContentId = subtopicContentId,
                        UserId            = userId,
                        Seen      = true,
                        CreatedOn = DateTime.Now
                    };

                    context.SubtopicContentUserMaps.Add(newEntity);
                    context.SaveChanges();
                    return(true);
                }
            }
            catch (Exception ex)
            {
                LogUtility.ErrorRoutine(ex);
                return(false);
            }
        }
Beispiel #8
0
        public bool AddAssignment(Assignment dataToAdd, out int id)
        {
            try
            {
                using (var context = new TrainingTrackerEntities())
                {
                    EntityFramework.Assignment newEntity = new EntityFramework.Assignment
                    {
                        Name            = dataToAdd.Name,
                        Description     = dataToAdd.Description,
                        AddedBy         = dataToAdd.AddedBy,
                        IsActive        = dataToAdd.IsActive,
                        CreatedOn       = dataToAdd.CreatedOn,
                        AssignmentAsset = dataToAdd.AssignmentAsset
                    };

                    context.Assignments.Add(newEntity);
                    context.SaveChanges();
                    id = newEntity.Id;
                    AddAssignmentSubtopicMapping(id, dataToAdd.CourseSubtopicId);
                    return(true);
                }
            }
            catch (Exception ex)
            {
                LogUtility.ErrorRoutine(ex);
                id = 0;
                return(false);
            }
        }
Beispiel #9
0
 /// <summary>
 /// Signature for method to update the Current User's and course Mapping
 /// </summary>
 /// <param name="currentUser">Session instance of current user</param>
 /// <param name="courseId">course id to be mapped</param>
 /// <returns>Status if mapping added or not.</returns>
 /// <exception >on exception return false</exception>
 public bool StartCourseForTrainee(Common.Entity.User currentUser, int courseId)
 {
     try
     {
         using (TrainingTrackerEntities context = new TrainingTrackerEntities())
         {
             if (!context.CourseUserMappings.Any(x => x.CourseId == courseId && x.UserId == currentUser.UserId))
             {
                 context.CourseUserMappings.Add(new CourseUserMapping
                 {
                     CourseId  = courseId,
                     UserId    = currentUser.UserId,
                     StartedOn = DateTime.Now
                 });
                 return(context.SaveChanges() == 1);
             }
             return(true);
         }
     }
     catch (Exception ex)
     {
         LogUtility.ErrorRoutine(ex);
         return(false);
     }
 }
Beispiel #10
0
 public bool AddQuestion(Question question)
 {
     try
     {
         var newQuestion = new EntityFramework.Question
         {
             QuestionText = question.QuestionText,
             Description  = question.Description,
             SkillId      = question.SkillId,
             AddedBy      = question.AddedBy,
             AddedDate    = question.AddedDate
         };
         using (var context = new TrainingTrackerEntities())
         {
             context.Questions.Add(newQuestion);
             context.SaveChanges();
         }
         return(AddQuestionMapping(question.LevelMapping, newQuestion.Id));
     }
     catch (Exception ex)
     {
         LogUtility.ErrorRoutine(ex);
         return(false);
     }
 }
Beispiel #11
0
        public bool UpdateCourseSubtopic(CourseSubtopic subtopicToUpdate)
        {
            try
            {
                using (var context = new TrainingTrackerEntities())
                {
                    var subtopicEntityToUpdate = context.CourseSubtopics.Find(subtopicToUpdate.Id);
                    if (subtopicEntityToUpdate == null)
                    {
                        return(false);
                    }

                    subtopicEntityToUpdate.Name        = subtopicToUpdate.Name;
                    subtopicEntityToUpdate.Description = subtopicToUpdate.Description;
                    subtopicEntityToUpdate.CourseId    = subtopicToUpdate.CourseId;

                    context.SaveChanges();
                    return(true);
                }
            }
            catch (Exception ex)
            {
                LogUtility.ErrorRoutine(ex);
                return(false);
            }
        }
Beispiel #12
0
 public int AddCourseSubtopic(CourseSubtopic subtopicToAdd)
 {
     try
     {
         using (var context = new TrainingTrackerEntities())
         {
             EntityFramework.CourseSubtopic newSubtopicEntity = new EntityFramework.CourseSubtopic
             {
                 Name        = subtopicToAdd.Name,
                 CourseId    = subtopicToAdd.CourseId,
                 Description = subtopicToAdd.Description,
                 SortOrder   = context.CourseSubtopics.Where(c => c.CourseId == subtopicToAdd.CourseId).Count() + 1,
                 AddedBy     = subtopicToAdd.AddedBy,
                 IsActive    = subtopicToAdd.IsActive,
                 CreatedOn   = subtopicToAdd.CreatedOn
             };
             context.CourseSubtopics.Add(newSubtopicEntity);
             context.SaveChanges();
             return(newSubtopicEntity.Id);
         }
     }
     catch (Exception ex)
     {
         LogUtility.ErrorRoutine(ex);
         return(0);
     }
 }
Beispiel #13
0
        /// <summary>
        /// Data Access method to Save response for the survey
        /// </summary>
        /// <param name="response">instance of response</param>
        /// <param name="survey">instance of survey</param>
        /// <returns>id of saved feedback</returns>
        public int SaveWeeklySurveyResponseForTrainee(Common.Entity.SurveyResponse response, Common.Entity.Survey survey)
        {
            try
            {
                using (TrainingTrackerEntities context = new TrainingTrackerEntities())
                {
                    SurveyCompletedMetaData instanceMetaData = new SurveyCompletedMetaData
                    {
                        SurveyId      = survey.SurveyId,
                        SurveyTakenBy = response.AddedBy.UserId,
                        DateCompleted = DateTime.Now
                    };

                    Feedback feedback = new Feedback
                    {
                        AddedBy      = response.Feedback.AddedBy.UserId,
                        AddedFor     = response.Feedback.AddedFor.UserId,
                        AddedOn      = DateTime.Now,
                        SkillId      = 0,
                        FeedbackText = response.Feedback.FeedbackText,
                        FeedbackType = response.Feedback.FeedbackType.FeedbackTypeId,
                        Title        = response.Feedback.FeedbackType.Description,
                        StartDate    = response.Feedback.StartDate,
                        EndDate      = response.Feedback.EndDate,
                        ProjectId    = 0,
                        Rating       = (short?)response.Feedback.Rating
                    };

                    foreach (var ans in response.Response)
                    {
                        instanceMetaData.SurveyResponses.Add(new SurveyResponse
                        {
                            SurveyQuestionId = ans.QuestionId,
                            SurveyAnswerId   = ans.AnswerId,
                            AdditionalNote   = ans.AdditionalNotes,
                            DateCreated      = DateTime.Now
                        });
                    }
                    context.SurveyCompletedMetaDatas.Add(instanceMetaData);
                    context.Feedbacks.Add(feedback);
                    context.WeeklyFeedbackSurveyMappings.Add(new WeeklyFeedbackSurveyMapping
                    {
                        FeedbackId = feedback.FeedbackId,
                        SurveyCompletedMetaDataId = instanceMetaData.SurveyCompletedMetaDataId
                    });
                    context.SaveChanges();
                    return(feedback.FeedbackId);
                }
            }
            catch (Exception ex)
            {
                LogUtility.ErrorRoutine(ex);
                return(-1);
            }
        }
Beispiel #14
0
        /// <summary>
        /// Add Learning Map data along with the mapping details of all courses and trainees included in the Learning Map(if any).
        /// </summary>
        /// <param name="data">Learning Map object which contain Learning map data along with the Course list(if any) and Trainee
        /// list(if any) included in the Learning map</param>
        /// <returns>Id of the Learning map if successfully added otherwise zero</returns>
        public int AddLearningMap(LearningMap data)
        {
            try
            {
                using (var context = new TrainingTrackerEntities())
                {
                    var newLearningMapEntity = new EntityFramework.LearningMap
                    {
                        Title                     = data.Title,
                        Notes                     = data.Notes,
                        Duration                  = data.Duration,
                        DateCreated               = DateTime.Now,
                        IsCourseRestricted        = data.IsCourseRestricted,
                        TeamId                    = data.TeamId,
                        CreatedBy                 = data.CreatedBy,
                        IsDeleted                 = data.IsDeleted,
                        LearningMapCourseMappings = (data.Courses != null) ? data.Courses.Select(x => new LearningMapCourseMapping
                        {
                            //LearningMapId = newLearningMapEntity.Id,
                            CourseId     = x.Id,
                            SortOrder    = x.SortOrder,
                            IsDeleted    = false,
                            DateInserted = DateTime.Now
                        }).ToList()
                                                                            : null,

                        LearningMapUserMappings = (data.Trainees != null) ? data.Trainees.Select(x => new LearningMapUserMapping
                        {
                            //LearningMapId = newLearningMapEntity.Id,
                            UserId       = x.UserId,
                            DateInserted = DateTime.Now
                        }).ToList()
                                                    : null
                    };


                    context.LearningMaps.Add(newLearningMapEntity);

                    context.SaveChanges();
                    return(newLearningMapEntity.Id);
                }
            }
            catch (Exception ex)
            {
                LogUtility.ErrorRoutine(ex);
                return(0);
            }
        }
Beispiel #15
0
        /// <summary>
        /// Calls stored procedure which updates user.
        /// </summary>
        /// <param name="userData">User data object.</param>
        /// <returns>True if updated.</returns>
        public bool UpdateUser(User userData)
        {
            if (userData.UserId <= 0)
            {
                return(false);
            }

            try
            {
                using (TrainingTrackerEntities context = new TrainingTrackerEntities())
                {
                    var userContext = context.Users.FirstOrDefault(x => x.UserId == userData.UserId);

                    if (userContext == null)
                    {
                        return(false);
                    }

                    userContext.FirstName          = userData.FirstName;
                    userContext.LastName           = userData.LastName;
                    userContext.UserName           = userData.UserName;
                    userContext.Email              = userData.Email;
                    userContext.Designation        = userData.Designation;
                    userContext.ProfilePictureName = userData.ProfilePictureName;
                    userContext.IsFemale           = userData.IsFemale;
                    userContext.IsAdministrator    = userData.IsAdministrator;
                    userContext.IsTrainer          = userData.IsTrainer;
                    userContext.IsTrainee          = userData.IsTrainee;
                    userContext.IsManager          = userData.IsManager;
                    userContext.IsActive           = userData.IsActive;
                    userContext.EmployeeId         = userData.EmployeeId;
                    if (!string.IsNullOrEmpty(userData.Password))
                    {
                        userContext.Password = userData.Password;
                    }
                    userContext.TeamId = userData.TeamId;

                    context.SaveChanges();
                    return(true);
                }
            }
            catch (Exception ex)
            {
                LogUtility.ErrorRoutine(ex);
                return(false);
            }
        }
Beispiel #16
0
 /// <summary>
 /// Clear All the pending Notification(except action type notification) for user
 /// </summary>
 /// <param name="userId">passed userid</param>
 /// <returns>success flag </returns>
 public bool MarkAllNotificationAsRead(int userId)
 {
     try
     {
         using (TrainingTrackerEntities context = new TrainingTrackerEntities())
         {
             context.UserNotificationMappings.Where(u => u.UserId == userId && !u.Seen && u.Notification.NotificationType != (int)Common.Enumeration.NotificationType.NewActionToPerform).ToList().ForEach(x => x.Seen = true);
             context.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         LogUtility.ErrorRoutine(ex);
         return(false);
     }
 }
Beispiel #17
0
 public bool DeleteAssignment(int id)
 {
     try
     {
         using (var context = new TrainingTrackerEntities())
         {
             var entity = context.Assignments.Find(id);
             entity.IsActive = false;
             context.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         LogUtility.ErrorRoutine(ex);
         return(false);
     }
 }
Beispiel #18
0
        /// <summary>
        /// Add Course
        /// </summary>
        /// <param name="courseToAdd">Course data object</param>
        /// <returns>Course Id of the added course if successful otherwise 0 </returns>
        public int AddCourse(Course courseToAdd)
        {
            try
            {
                using (var context = new TrainingTrackerEntities())
                {
                    EntityFramework.Course newCourseEntity = ModelMapper.MapToCourseModel(courseToAdd);

                    context.Courses.Add(newCourseEntity);
                    context.SaveChanges();
                    return(newCourseEntity.Id);
                }
            }
            catch (Exception ex)
            {
                LogUtility.ErrorRoutine(ex);
                return(0);
            }
        }
Beispiel #19
0
 public bool AddSkill(Skill skill)
 {
     try
     {
         using (var context = new TrainingTrackerEntities())
         {
             context.Skills.Add(new EntityFramework.Skill
             {
                 Name    = skill.Name,
                 AddedBy = skill.AddedBy,
                 AddedOn = DateTime.Now
             });
             return(context.SaveChanges() > 0);
         }
     }
     catch (Exception ex)
     {
         LogUtility.ErrorRoutine(ex);
         return(false);
     }
 }
Beispiel #20
0
        public bool UpdateAssignment(Assignment dataToUpdate)
        {
            try
            {
                using (var context = new TrainingTrackerEntities())
                {
                    var entity = context.Assignments.Where(a => a.IsActive && a.Id == dataToUpdate.Id).FirstOrDefault();
                    entity.AssignmentAsset = dataToUpdate.AssignmentAsset;
                    entity.Description     = dataToUpdate.Description;
                    entity.Name            = dataToUpdate.Name;

                    context.SaveChanges();
                    return(true);
                }
            }
            catch (Exception ex)
            {
                LogUtility.ErrorRoutine(ex);
                return(false);
            }
        }
Beispiel #21
0
 /// <summary>
 /// Add mapping data for the Assignment and Feedback in AssignmentFeedbackMapping table
 /// </summary>
 /// <param name="feedbackId">Id of the added feedback</param>
 /// <param name="assignmentId">Id of the assignment for which feedback is added</param>
 /// <returns> true if successfully adds the mapping data otherwise false</returns>
 public bool AddFeedbackAssignmentMapping(int feedbackId, int assignmentId)
 {
     try
     {
         using (var context = new TrainingTrackerEntities())
         {
             var newMappingEntity = new EntityFramework.AssignmentFeedbackMapping
             {
                 AssignmentId = assignmentId,
                 FeedbackId   = feedbackId
             };
             context.AssignmentFeedbackMappings.Add(newMappingEntity);
             return(context.SaveChanges() > 0);
         }
     }
     catch (Exception ex)
     {
         LogUtility.ErrorRoutine(ex);
         return(false);
     }
 }
Beispiel #22
0
        /// <summary>
        /// Update notification as make seen status true.
        /// </summary>
        /// <param name="userId">UserId</param>
        /// <param name="notification">Notification object</param>
        /// <returns>Returns boolean value according to Notification is added successfully or not</returns>
        public bool UpdateNotification(int userId, Common.Entity.Notification notification)
        {
            try
            {
                using (TrainingTrackerEntities context = new TrainingTrackerEntities())
                {
                    context.UserNotificationMappings
                    .Where(s => s.UserId == userId && !s.Seen && s.NotificationId == notification.NotificationId)
                    .ToList()
                    .ForEach(s => { s.Seen = true; });

                    context.SaveChanges();
                    return(true);
                }
            }
            catch (Exception ex)
            {
                LogUtility.ErrorRoutine(ex);
                return(false);
            }
        }
Beispiel #23
0
        /// <summary>
        /// Dal method to Add feedback
        /// </summary>
        /// <param name="feedbackData">feedback instance</param>
        /// <returns>int of feedback</returns>
        public int AddFeedback(Feedback feedbackData)
        {
            try
            {
                var feedback = new EntityFramework.Feedback
                {
                    FeedbackText = feedbackData.FeedbackText.Trim(),
                    Title        = feedbackData.Title,
                    FeedbackType = feedbackData.FeedbackType.FeedbackTypeId,
                    ProjectId    = feedbackData.Project.ProjectId,
                    SkillId      = feedbackData.Skill.SkillId,
                    Rating       = (short?)feedbackData.Rating,
                    AddedBy      = feedbackData.AddedBy.UserId,
                    AddedFor     = feedbackData.AddedFor.UserId,
                    StartDate    = feedbackData.StartDate,
                    EndDate      = feedbackData.EndDate,
                    AddedOn      = feedbackData.AddedOn == DateTime.MinValue ? DateTime.Now : feedbackData.AddedOn
                };

                using (var context = new TrainingTrackerEntities())
                {
                    context.Feedbacks.Add(feedback);
                    context.SaveChanges();

                    // Add new mapping for user and skill
                    if (feedbackData.FeedbackType.FeedbackTypeId == (int)Common.Enumeration.FeedbackType.Skill)
                    {
                        SkillDal.AddUserSkillMapping(feedbackData.Skill.SkillId, feedbackData.AddedFor.UserId, feedbackData.AddedBy.UserId);
                    }

                    return(feedback.FeedbackId);
                }
            }
            catch (Exception ex)
            {
                LogUtility.ErrorRoutine(ex);
                return(0);
            }
        }
Beispiel #24
0
        /// <summary>
        /// Calls stored procedure which adds user.
        /// </summary>
        /// <param name="userData">User data object.</param>
        /// <param name="userId">Out parameter created UserId.</param>
        /// <returns>True if added.</returns>
        public bool AddUser(User userData, out int userId)
        {
            userId = 0;
            try
            {
                using (TrainingTrackerEntities context = new TrainingTrackerEntities())
                {
                    EntityFramework.User objUser = new EntityFramework.User
                    {
                        FirstName          = userData.FirstName,
                        LastName           = userData.LastName,
                        UserName           = userData.UserName,
                        Password           = userData.Password,
                        Email              = userData.Email,
                        Designation        = userData.Designation,
                        ProfilePictureName = userData.ProfilePictureName,
                        IsFemale           = userData.IsFemale,
                        IsAdministrator    = userData.IsAdministrator,
                        IsTrainer          = userData.IsTrainer,
                        IsTrainee          = userData.IsTrainee,
                        IsManager          = userData.IsManager,
                        DateAddedToSystem  = DateTime.Now,
                        IsActive           = userData.IsActive,
                        TeamId             = userData.TeamId,
                        EmployeeId         = userData.EmployeeId
                    };

                    context.Users.Add(objUser);
                    context.SaveChanges();
                    userId = objUser.UserId;
                    return(true);
                }
            }
            catch (Exception ex)
            {
                LogUtility.ErrorRoutine(ex);
                return(false);
            }
        }
Beispiel #25
0
        /// <summary>
        /// Data access method to update the course status to completed for trainee
        /// </summary>
        /// <param name="courseId">course Id to be updated</param>
        /// <param name="traineeId">trainee Id to be updated</param>
        /// <returns>success flag for updation of the context</returns>
        public bool CompleteCourseForTrainee(int courseId, int traineeId)
        {
            try
            {
                using (TrainingTrackerEntities context = new TrainingTrackerEntities())
                {
                    CourseUserMapping courseUserMap = context.CourseUserMappings.FirstOrDefault(x => x.CourseId == courseId && x.UserId == traineeId && x.CompletedOn == null);

                    if (courseUserMap != null)
                    {
                        courseUserMap.CompletedOn = DateTime.Now;
                        return(context.SaveChanges() == 1);
                    }
                    throw new Exception("No course user mapping already existing");
                }
            }
            catch (Exception ex)
            {
                LogUtility.ErrorRoutine(ex);
                return(false);
            }
        }
Beispiel #26
0
 public bool PublishCourse(int id)
 {
     try
     {
         using (var context = new TrainingTrackerEntities())
         {
             var course = context.Courses.Find(id);
             if (course != null)
             {
                 course.IsPublished = true;
                 context.SaveChanges();
                 return(true);
             }
             return(false);
         }
     }
     catch (Exception ex)
     {
         LogUtility.ErrorRoutine(ex);
         return(false);
     }
 }
Beispiel #27
0
        public bool AddAssignmentSubtopicMapping(int assignmentId, int subtopicId)
        {
            try
            {
                using (var context = new TrainingTrackerEntities())
                {
                    EntityFramework.AssignmentSubtopicMap newEntity = new EntityFramework.AssignmentSubtopicMap
                    {
                        AssignmentId = assignmentId,
                        SubtopicId   = subtopicId
                    };

                    context.AssignmentSubtopicMaps.Add(newEntity);
                    context.SaveChanges();
                    return(true);
                }
            }
            catch (Exception ex)
            {
                LogUtility.ErrorRoutine(ex);
                return(false);
            }
        }
Beispiel #28
0
 /// <summary>
 /// Add New Thread to Feedback
 /// </summary>
 /// <param name="thread">instance of thread</param>
 /// <returns>Succes event of flag</returns>
 public bool AddNewThread(Threads thread)
 {
     try
     {
         using (TrainingTrackerEntities context = new TrainingTrackerEntities())
         {
             context.FeedbackThreads.Add(new FeedbackThread
             {
                 FeedbackId       = thread.FeedbackId,
                 Comments         = thread.Comments,
                 DateTimeInserted = DateTime.Now,
                 AddedBy          = thread.AddedBy.UserId,
             });
             context.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         LogUtility.ErrorRoutine(ex);
         return(false);
     }
 }
Beispiel #29
0
        public bool DeleteSubtopicContent(int id)
        {
            try
            {
                using (var context = new TrainingTrackerEntities())
                {
                    var entityToDelete = context.SubtopicContents.Find(id);
                    if (entityToDelete == null)
                    {
                        return(false);
                    }

                    entityToDelete.IsActive = false;
                    context.SaveChanges();
                    return(true);
                }
            }
            catch (Exception ex)
            {
                LogUtility.ErrorRoutine(ex);
                return(false);
            }
        }
Beispiel #30
0
        public bool SaveSubtopicContentOrder(List <SubtopicContent> data)
        {
            try
            {
                using (var context = new TrainingTrackerEntities())
                {
                    data.ForEach(x =>
                    {
                        var entity       = context.SubtopicContents.Find(x.Id);
                        entity.SortOrder = x.SortOrder;
                        context.SaveChanges();
                    }
                                 );

                    return(true);
                }
            }
            catch (Exception ex)
            {
                LogUtility.ErrorRoutine(ex);
                return(false);
            }
        }