Ejemplo n.º 1
0
 public List <Skill> AddSkill(Skill category)
 {
     if (SkillDataAccesor.AddSkill(category))
     {
         return(SkillDataAccesor.GetAllSkillsForApp());
     }
     return(null);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Add New feedback for user
        /// </summary>
        /// <param name="feedback">instance of feedback object</param>
        /// <returns>success flag wether feedback was added or not</returns>
        public bool AddFeedback(Feedback feedback)
        {
            feedback.Project = feedback.Project ?? new Project();

            if (feedback.FeedbackType.FeedbackTypeId == (int)FeedbackType.Skill)
            {
                if (!string.IsNullOrEmpty(feedback.Title))
                {
                    Skill newSkill = new Skill
                    {
                        Name    = feedback.Title,
                        AddedBy = feedback.AddedBy.UserId,
                        AddedOn = DateTime.Now
                    };

                    newSkill.SkillId = SkillDataAccesor.AddNewSkillForId(newSkill);

                    //Since new skill update the skill data
                    feedback.Skill.SkillId = newSkill.SkillId;
                    feedback.Skill.Name    = feedback.Title;
                }

                feedback.Title = feedback.Skill.Name;
                feedback.Skill = new Skill
                {
                    SkillId = feedback.Skill.SkillId
                };
            }
            else
            {
                feedback.Skill = new Skill();
            }

            // no way comment can have feedback rating
            if (feedback.FeedbackType.FeedbackTypeId == (int)FeedbackType.Comment || feedback.FeedbackType.FeedbackTypeId == (int)FeedbackType.Course)
            {
                feedback.Rating = 0;
            }

            feedback.Title = string.IsNullOrEmpty(feedback.Title) ? feedback.FeedbackType.Description : feedback.Title;

            int feedbackId = FeedbackDataAccesor.AddFeedback(feedback);

            if (!(feedbackId > 0))
            {
                return(false);
            }

            feedback.FeedbackId = feedbackId;

            return(new NotificationBl().AddFeedbackNotification(feedback));
        }