public ActionResult AjaxReply()
        {
            var questionModel = new FAQ_Question
            {
                IsShow = true
            };

            if (Request["do"] != null && Request["do"] == "reply")
            {
                questionModel = _questionDa.GetById(ArrId.FirstOrDefault());
            }
            ViewBag.CategoryID = _categoryDa.GetChildByParentId(true, (int)ModuleType.FAQ);
            ViewData.Model     = questionModel;
            ViewBag.Action     = "reply";
            ViewBag.ActionText = ActionText;
            return(View());
        }
        public ActionResult AjaxForm()
        {
            var questionModel = new FAQ_Question
            {
                IsShow = true
            };

            if (DoAction == ActionType.Edit)
            {
                questionModel = _questionDa.GetById(ArrId.FirstOrDefault());
            }
            ViewBag.CategoryID = _categoryDa.GetChildByParentId(false, (int)ModuleType.FAQ);
            ViewData.Model     = questionModel;
            ViewBag.Action     = DoAction;
            ViewBag.ActionText = ActionText;
            return(View());
        }
        public ActionResult Actions()
        {
            var msg      = new JsonMessage();
            var question = new FAQ_Question();
            List <FAQ_Question> ltsQuestionItems;
            StringBuilder       stbMessage;

            if (Request["do"] != null && Request["do"] == "reply")
            {
                try
                {
                    question = _questionDa.GetById(ArrId.FirstOrDefault());
                    var content = question.Content;
                    UpdateModel(question);
                    if (question.FAQ_Answer != null && question.FAQ_Answer.FirstOrDefault() != null)
                    {
                        var answer = question.FAQ_Answer.FirstOrDefault();
                        if (answer != null)
                        {
                            answer.Content     = question.Content;
                            question.Content   = content;
                            answer.DateCreated = DateTime.Now;
                            answer.IsShow      = true;
                        }
                    }
                    else
                    {
                        var faqAnswer = new FAQ_Answer {
                            Content = question.Content
                        };
                        question.Content      = content;
                        faqAnswer.DateCreated = DateTime.Now;
                        faqAnswer.IsShow      = true;

                        if (question.FAQ_Answer != null)
                        {
                            question.FAQ_Answer.Add(faqAnswer);
                        }
                    }

                    _questionDa.Save();
                    msg = new JsonMessage
                    {
                        Erros   = false,
                        Message = "Đã trả lời câu hỏi"
                    };
                }
                catch (Exception)
                {
                }
                return(Json(msg, JsonRequestBehavior.AllowGet));
            }
            switch (DoAction)
            {
            case ActionType.Add:
                UpdateModel(question);
                question.TitleAscii  = FDIUtils.Slug(question.Title);
                question.DateCreated = DateTime.Now;
                question.LanguageId  = Fdisystem.LanguageId;
                _questionDa.Add(question);
                _questionDa.Save();
                msg = new JsonMessage
                {
                    Erros   = false,
                    ID      = question.ID.ToString(),
                    Message = string.Format("Đã thêm mới câu hỏi: <b>{0}</b>", Server.HtmlEncode(question.Title))
                };
                break;

            case ActionType.Edit:
                question = _questionDa.GetById(ArrId.FirstOrDefault());
                UpdateModel(question);
                _questionDa.Save();
                msg = new JsonMessage
                {
                    Erros   = false,
                    ID      = question.ID.ToString(),
                    Message = string.Format("Đã cập nhật câu hỏi: <b>{0}</b>", Server.HtmlEncode(question.Title))
                };
                break;

            case ActionType.Delete:
                ltsQuestionItems = _questionDa.GetListByArrId(ArrId);
                stbMessage       = new StringBuilder();
                foreach (var item in ltsQuestionItems)
                {
                    _questionDa.Delete(item);
                    stbMessage.AppendFormat("Đã xóa câu hỏi <b>{0}</b>.<br />", Server.HtmlEncode(item.Title));
                }
                msg.ID = string.Join(",", ArrId);
                _questionDa.Save();
                msg.Message = stbMessage.ToString();
                break;

            case ActionType.Show:
                ltsQuestionItems = _questionDa.GetListByArrId(ArrId).Where(o => o.IsShow == false).ToList();
                stbMessage       = new StringBuilder();
                foreach (var item in ltsQuestionItems)
                {
                    item.IsShow = true;
                    stbMessage.AppendFormat("Đã hiển thị câu hỏi <b>{0}</b>.<br />", Server.HtmlEncode(item.Title));
                }
                _questionDa.Save();
                msg.ID      = string.Join(",", ltsQuestionItems.Select(o => o.ID));
                msg.Message = stbMessage.ToString();
                break;

            case ActionType.Hide:
                ltsQuestionItems = _questionDa.GetListByArrId(ArrId).Where(o => o.IsShow == true).ToList();
                stbMessage       = new StringBuilder();
                foreach (var item in ltsQuestionItems)
                {
                    item.IsShow = false;
                    stbMessage.AppendFormat("Đã ẩn câu hỏi <b>{0}</b>.<br />", Server.HtmlEncode(item.Title));
                }
                _questionDa.Save();
                msg.ID      = string.Join(",", ltsQuestionItems.Select(o => o.ID));
                msg.Message = stbMessage.ToString();
                break;
            }
            if (string.IsNullOrEmpty(msg.Message))
            {
                msg.Message = "Không có hành động nào được thực hiện.";
                msg.Erros   = true;
            }
            return(Json(msg, JsonRequestBehavior.AllowGet));
        }
        // D Mitchell
        public void SetupFAQTables()
        {
            string[] FAQ_Questions_Common =
                new string[]
            {
                "How do I become a ",
                "What education do I need and how do I get it (what schools/training program do you recommend)?",
                "What skills do I need and how do I get  them?",
                "Where can I get help on Immigration issues?",
                "Where is most of the hiring?",
                "Do I have to join a union? How do I join a Union?",
                "What can I do about Financial Aid?",
                "Whats the best way to apply?",
                "Whats the best way to network?",
                "Where can I go for more assistance?"
            };

            string[] Occupation_Names_Healthcare =
                new string[]
            {
                "Licensed Practical and Licensed Vocational Nurses",
                "Dental Hygienists", "Radiologic Technologists and Technicians",
                "Respiratory Therapists", "Nursing Aides, Orderlies, and Attendants",
                "Medical Records and Health Information Technicians",
                "Cardiovascular Technologists and Technicians",
                "Physical Therapist Assistants",
                "Medical Equipment Repairers",
                "Health Technologists and Technicians, All Other"
            };

            string[] FAQ_Responses_Healthcare =
                new string[]
            {
                "Depending on the choices, most require an employee to complete a degree program and obtain practicum through clinicals and internships. I would suggest speaking with a current professional, especially since the global economy changed the nature of many of these careers. For an example, biotechnology will be incorporated in healthcare careers. http://www.bls.gov/ooh/ is a great website that provides basic information about the growth of industries, how to enter the field, degree requirement, and potential work environment. Also, almost every field has national and international associations where they can network with professionals in their chosen field so they can educate an interested about how to enter the field of their choice.",
                "For anyone that is interested in any of these professions, they will have to research community colleges, trade schools, and 4 year schools in their area. Depending on the program, some may take only 18 – 24 months, while other will require 4 years for completion. The best advice is to speak with advisors and representatives at colleges to see if they offer these programs and find out about the admission process. Some programs, such as Respiratory therapy and RN, may require a student to pass an exam and apply for the program after they complete prerequisites.",
                "Depends on the occupation. The most important skills are communication/writing skills, math/science in the health care field, critical thinking, customer service, teamwork, the ability to work independently, and computer skills. An interested candidate must attend post-secondary institutions to develop most of these skills.",
                "Contact school counselors about how immigration status will impact eligibility to attend post-secondary institutions and trade schools. Also, contact occupation boards, such as nursing and respiratory therapy to determine how immigration status impacts eligibility to receive licenses/certifications.",
                "Most hiring places are in larger/public institutions. Private institutions require fewer workers, therefore, interested candidates will have to pursue more creative networking strategies, such as attending social events, connecting with them on social networks, and attending conferences to meet with professionals with private practices and market their skills. The job market is about whom you know, so connecting with professionals on a social level will increase an applicant’s chance of obtaining employment. ",
                "Depends on the employer and the location of the job. Northeast and Midwest has a stronger union presence than the south. Also, public institutions will more likely require employees to join unions.",
                "They must file FASFA, online, to determine if they are eligible for funding, which depends on income status. Interested candidates must speak with a school F/A counselor of their choice. Every schools conduct financial aid workshops that educate potential students on how to properly file financial aid and apply for scholarships.",
                "Research schools of interest and apply according to the admission process. Contact a school advisor to determine chances of entering the institutions. Community colleges typically have open admission policy, which means that they can apply up to the deadline of course registration and will automatically get accepted to the school. Four year institutions and trade schools have more restrictive application and deadline policies. Make sure interested applicants find out if institutions offer a program of their choice and program entrance policies before applying for the school.",
                "As stated earlier, obtaining employment is about “who you know”. Research and become members of national organizations, which provides benefits such as discounts for workshops/conferences, social events, newsletters, and certifications. Most organizations allow members to participate in committees so they can become actively involve with these organizations and network with other members. Interested candidates should reach out to professionals and program departments at their school to ask about internship and job shadowing opportunities. They should, also, volunteer in community programs that relates to the field of their choice. Interested candidates should contact their inner circles, such as close friends, relatives, or mentors that are already in the field to determine hiring possibilities. Networking should start at an early stage of the career transition process.",
                "First step is candidates should speak with academic advisors about the application/financial aid process, course requirements, and potential internship opportunities. Once candidates start their education process, then they should start the networking with hopes of landing a position after graduation."
            };

            using (BlueDbContext context = new BlueDbContext())
            {
                // Delete existing data
                StringBuilder sb = new StringBuilder();

                sb.Append("DELETE FROM FAQ_Question; DELETE FROM FAQ_Response;");
                sb.Append("DELETE FROM FAQ_QuestionSource; DELETE FROM FAQ_ResponseSource;");

                context.Database.ExecuteSqlCommand(sb.ToString());

                // FAQ Sourcer
                var fqs =
                    new FAQ_QuestionSource()
                {
                    Name = "Joey Blow"
                };

                context.FAQ_QuestionSources.Add(fqs);

                // FAQ Responder
                var frs =
                    new FAQ_ResponseSource()
                {
                    Organization = "Workforce Advisor"
                };

                context.FAQ_ResponseSources.Add(frs);

                context.SaveChanges();  // Both added to database

                //  Assoicate each occupation in Occupations entity
                //  with standard FAQ questions and responses
                foreach (var oc in context.Ocuppations)
                {
                    foreach (string question in FAQ_Questions_Common)
                    {
                        string bufferOCCname         = string.Empty;
                        string bufferResponseContent = "Unknown";

                        if (question.Contains(FAQ_Questions_Common[0]))
                        {
                            bufferOCCname = oc.Name;
                        }

                        // Instantiate a new FAQ_Question
                        var fq =
                            new FAQ_Question()
                        {
                            Text = (question + " " + bufferOCCname).Trim(),
                            FAQ_QuestionSource = fqs,
                            Occupation         = oc
                        };

                        int responseIndex = Array.FindIndex(Occupation_Names_Healthcare, element => element.Contains(oc.Name));

                        if (responseIndex != -1)
                        {
                            bufferResponseContent = FAQ_Responses_Healthcare[responseIndex];
                        }

                        // Instantiate a new FAQ_Response
                        var fr =
                            new FAQ_Response()
                        {
                            Text = bufferResponseContent,
                            FAQ_ResponseSource = frs
                        };

                        //  Incorporate new question and response according to the entity model
                        fq.FAQ_Responses.Add(fr);    // Link the response to the question
                        context.FAQ_Questions.Add(fq);
                    }
                }

                context.SaveChanges();  // Update the database using the entity model
            }
        }
Exemple #5
0
 public void Delete(FAQ_Question faqQuestion)
 {
     //  foreach (var answer in faqQuestion.FAQ_Answer)
     //    FDIDB.FAQ_Answer.Remove(answer); //Xóa câu hỏi
     FDIDB.FAQ_Question.Remove(faqQuestion); // Xóa câu trả lời
 }
Exemple #6
0
 public void Add(FAQ_Question faqQuestion)
 {
     FDIDB.FAQ_Question.Add(faqQuestion);
 }