private void UpdateProducts(FaqModel product)
        {
            var index = Faqs.IndexOf(product);

            Faqs.Remove(product);
            Faqs.Insert(index, product);
        }
        public static bool Create(FaqModel faqModel)
        {
            using (var client = new LandauPortalWebAPI())
            {
                var question = new Question();

                question.Brand     = faqModel.Brand;
                question.FirstName = faqModel.FirstName;
                question.LastName  = faqModel.LastName;
                question.Phone     = faqModel.Phone;
                question.Email     = faqModel.Email;
                question.Comments  = faqModel.Comments;

                try
                {
                    client.Questions.CreateQuestions(question.Brand, question);
                    return(true);
                }
                catch (Exception e)
                {
                    if (e is HttpOperationException)
                    {
                        var httpEx = (HttpOperationException)e;
                        return(httpEx.Response.IsSuccessStatusCode);
                    }
                }

                return(false);
            }
        }
Example #3
0
        public Response <FaqModel> UpdateFaq(FaqModel model)
        {
            string ReturnLink = string.Empty;

            Response <FaqModel> returnModel = new Response <FaqModel>();

            try
            {
                using (SqlConnection DB = new SqlConnection(SiteKey.ConnectionString))
                {
                    DB.ExecuteSql(@"update faq set question = @question, answer = @answer, question_arabic = @question_arabic, answer_arabic = @answer_arabic where id = @id ", new
                    {
                        id = model.id,
                        model.question,
                        model.question_arabic,
                        model.answer,
                        model.answer_arabic,
                    });
                }

                returnModel.status = (int)EnumClass.ResponseState.Success;
                returnModel.msg    = Resource_Kharban.UpdateSuccessfully;
            }
            catch (Exception ex)
            {
                returnModel.msg    = ex.Message;
                returnModel.status = (int)EnumClass.ResponseState.ResposityError;
                LoggingRepository.SaveException(ex);
            }
            return(returnModel);
        }
Example #4
0
        public Response <FaqModel> AddFaq(FaqModel model)
        {
            Response <FaqModel> returnModel = new Response <FaqModel>();

            try
            {
                using (SqlConnection DB = new SqlConnection(SiteKey.ConnectionString))
                {
                    DB.ExecuteSql(@"insert into faq values(@id,@question,@question_arabic,@answer,@answer_arabic,@status,@is_deleted,@created,@modified,@faq_for) ", new
                    {
                        id = Guid.NewGuid().ToString(),
                        model.question,
                        model.question_arabic,
                        model.answer,
                        model.answer_arabic,
                        model.status,
                        model.faq_for,
                        is_deleted = 0,
                        modified   = DateTime.Now,
                        created    = DateTime.Now,
                    });
                }

                returnModel.success = true;
                returnModel.status  = (int)EnumClass.ResponseState.Success;
                returnModel.msg     = Resource_Kharban.InsertSuccessfully;
            }
            catch (Exception ex)
            {
                returnModel.msg    = ex.Message;
                returnModel.status = (int)EnumClass.ResponseState.ResposityError;
                LoggingRepository.SaveException(ex);
            }
            return(returnModel);
        }
        public ActionResult Index()
        {
            InitController();
            FaqModel faqModel = new FaqModel();

            faqModel.Brand = this.CurrentBrand;
            return(View(PathFromView("Faq"), faqModel));
        }
Example #6
0
 public static void UpdateModel(this Faq faq,
                                FaqModel model)
 {
     faq.Id        = model.Id;
     faq.Title     = model.Title;
     faq.Content   = model.Content;
     faq.IsDisplay = model.IsDisplay;
 }
Example #7
0
 public async Task <IActionResult> Create(FaqModel model)
 {
     if (ModelState.IsValid)
     {
         return(await CreateUpdateFaq(model, false));
     }
     return(View(model));
 }
Example #8
0
        public async Task <ActionResult> Put([FromBody] FaqModel faq)
        {
            faq.upd_dt   = DateTime.Now;
            faq.upd_user = User.Identity.Name;
            await _faq.Update(faq);

            return(Ok());
        }
 public ICollection <Category> GetAllCategories()
 {
     using (var entity = new FaqModel())
     {
         var cats = entity.Categories.ToList();
         return(cats);
     }
 }
 public ICollection <SubmittedQuestion> GetAllSubmittedQuestions()
 {
     using (var entity = new FaqModel())
     {
         var sqs = entity.SubmittedQuestions.Include("Category").ToList();
         return(sqs);
     }
 }
Example #11
0
 public async Task Update(FaqModel faqModel)
 {
     _context.Entry(faqModel).Property(x => x.faq_nm).IsModified   = true;
     _context.Entry(faqModel).Property(x => x.content).IsModified  = true;
     _context.Entry(faqModel).Property(x => x.upd_dt).IsModified   = true;
     _context.Entry(faqModel).Property(x => x.upd_user).IsModified = true;
     await _context.SaveChangesAsync();
 }
Example #12
0
        public IActionResult GetFaqList([FromBody] FaqModel model)
        {
            if (model == null)
            {
                model = new FaqModel();
            }
            Response <List <FaqModel> > returnModel = new FaqRepository().GetFaqList(model);

            return(Ok(returnModel));
        }
Example #13
0
        public ActionResult GetFaq(FaqModel model)
        {
            if (model == null)
            {
                model = new FaqModel();
            }
            Response <FaqModel> returnModel = new SettingRepository().GetFaq(model);

            return(Ok(returnModel));
        }
Example #14
0
        public async Task <ActionResult> Delete(int seq)
        {
            FaqModel faqs = new FaqModel
            {
                faq_seq = seq
            };
            await _faq.Delete(faqs);

            return(Ok());
        }
        public IActionResult Index()
        {
            var    vm            = new FaqModel();
            var    stringService = new StringService();
            string original      = "Det var en gamal gubbe";

            vm.CuttingExample = stringService.CutString(original, 5);

            return(View(vm));
        }
Example #16
0
        public IActionResult UpdateStatusFaq([FromBody] FaqModel model)
        {
            if (model == null)
            {
                model = new FaqModel();
            }
            Response <FaqModel> returnModel = new FaqRepository().UpdateStatusFaq(model);

            return(Ok(returnModel));
        }
Example #17
0
 public async Task <IActionResult> ActiveFaq(FaqModel hnm)
 {
     try
     {
         return(new JsonResult(await _faqrepo.LogicalAvailable(hnm.FA_Id, true)));
     }
     catch (Exception ex)
     {
         return(new JsonResult(ResponseModel.ServerInternalError(data: ex)));
     }
 }
Example #18
0
 public async Task <IActionResult> UpdateFaq(FaqModel hnm)
 {
     try
     {
         return(new JsonResult(await _faqrepo.Update(hnm)));
     }
     catch (Exception ex)
     {
         return(new JsonResult(ResponseModel.ServerInternalError(data: ex)));
     }
 }
        public IActionResult Index()
        {
            ViewBag.CurrentPage = "Faq";

            var model = new FaqModel
            {
                Questions = _questionService.GetAll()
            }
            ;

            return(View(model));
        }
        public ICollection <FaqItem> GetAllItems()
        {
            using (var entity = new FaqModel())
            {
                //for å vis loading process i anguler module
                Thread.Sleep(5000);//sleep 5 sec
                var faqs = entity.FaqItems.Include("Category").Include("Answers").ToList();


                return(faqs);
            }
        }
Example #21
0
        public ActionResult Index()
        {
            FaqModel model = new FaqModel();

            //Populate Model
            model.Populate(TSMContext.CurrentPage, TSMContext.CurrentLanguageID);

            ViewBag.PageTitle       = model.Page_Language.PageTitle;
            ViewBag.PageDescription = model.Page_Language.PageMetadata;
            ViewBag.PageKeywords    = model.Page_Language.PageKeywords;

            return(View("~/Views/FAQ/FAQ.cshtml", model));
        }
        public bool SubmitAnswer(SubmittedQuestion item)
        {
            try
            {
                using (var entity = new FaqModel())
                {
                    var question = entity.SubmittedQuestions.FirstOrDefault(q => q.SubmittedQuestionId == item.SubmittedQuestionId);
                    question.Answer = item.Answer;
                    var res = entity.SaveChanges();
                }

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Example #23
0
        public ActionResult Add(FaqModel model)
        {
            if (ModelState.IsValid)
            {
                Faq faq = new Faq();
                faq.UpdateModel(model);
                UpdateResult result = _faqService.Add(faq);
                if (result.State == 1)
                {
                    ViewBag.Completed = true;
                }
                else
                {
                    ViewBag.Completed = false;
                }
            }

            return(View(model));
        }
Example #24
0
        public IGenericResponseResult Index(string lang = null, string search = null)
        {
            /*
             * var lstFromMetadata = (ApplicationConfiguration.IsProd) ? GetList() : GetMockedList();
             * if (lstFromMetadata.Any(treeData => treeData.SolutionId != Convert.ToInt32(treeData.Description.Substring(1, 4))))
             * {
             *  throw new NotImplementedException();
             * }
             */
            var listToUse = ApplicationConfiguration.IsProd() ? new FaqUtils().GetList() : FaqUtils.GetMockedList();
            //var listToUse = ApplicationConfiguration.IsProd() ? new FaqUtils().GetList() : new FaqUtils().GetList();
            var tree  = GetTree(listToUse, lang, search);
            var model = new FaqModel(tree)
            {
                Lang = lang, Search = search
            };

            return(new GenericResponseResult <FaqModel>(model, null));
        }
        public bool FaqViewCountAdd(SubmittedQuestion item)
        {
            try
            {
                using (var entity = new FaqModel())
                {
                    var fq = entity.SubmittedQuestions.FirstOrDefault(f => f.SubmittedQuestionId == item.SubmittedQuestionId);
                    fq.ViewCount++;

                    var res = entity.SaveChanges();
                }

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
        public ActionResult Index(FaqModel faqModel)
        {
            InitController();

            if (ModelState.IsValid)
            {
                faqModel.Brand = this.CurrentBrand;

                var ok = FaqManager.Create(faqModel);
                if (ok)
                {
                    return(RedirectToAction("ThankYou"));
                }
                return(RedirectToAction("Index"));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
        public void ShowOrHidePoducts(FaqModel faq)
        {
            if (_oldProduct == faq)
            {
                faq.IsVisible = !faq.IsVisible;
                UpdateProducts(faq);
            }
            else
            {
                if (_oldProduct != null)
                {
                    _oldProduct.IsVisible = false;
                    UpdateProducts(_oldProduct);
                }
                faq.IsVisible = true;
                UpdateProducts(faq);
            }

            _oldProduct = faq;
        }
Example #28
0
        public async Task <ActionResult <Faq> > PostFaq(FaqModel faqModel)
        {
            var result = new Result <Faq>();
            Faq faq    = new Faq();

            _mapper.Map(faqModel, faq);
            try
            {
                result.Data = faq;
                await _context.Faq.AddAsync(faq);

                await _context.SaveChangesAsync();
            }
            catch (Exception e)
            {
                result.ErrorMessage = e.Message;
                result.IsFound      = false;
            }
            return(Ok(result));
        }
Example #29
0
        private async Task <IActionResult> CreateUpdateFaq(FaqModel model, bool update)
        {
            Faq faq             = new Faq();
            var displayForRoles = model.DisplayForRoles.SelectedItems.Select(r => EnumHelper.Parse <DisplayUserRole>(r.Value));

            if (update)
            {
                var faqDisplayUserRolesWithFaq = await _dbContext.FaqDisplayUserRole.GetFaqWithFaqDisplayUserRolesByFaqId(model.FaqId).ToListAsync();

                faq = faqDisplayUserRolesWithFaq.Select(f => f.Faq).First();
                faq.Update(_clock.SwedenNow, User.GetUserId(), model.IsDisplayed, model.Question, model.Answer, displayForRoles);
            }
            else
            {
                faq.Create(_clock.SwedenNow, User.GetUserId(), model.IsDisplayed, model.Question, model.Answer, displayForRoles);
                await _dbContext.AddAsync(faq);
            }
            await _dbContext.SaveChangesAsync();

            return(RedirectToAction("List"));
        }
Example #30
0
        public ActionResult Edit(FaqModel model)
        {
            if (ModelState.IsValid)
            {
                Faq faq = _faqService.GetById(model.Id);
                if (faq != null)
                {
                    faq.UpdateModel(model);
                    UpdateResult result = _faqService.Update(faq);
                    if (result.State == 1)
                    {
                        ViewBag.Completed = true;
                    }
                    else
                    {
                        ViewBag.Completed = false;
                    }
                }
            }

            return(View(model));
        }