public IHttpActionResult UpdateFAQ(FAQDto fAQDto) { var faq = entity.faqs.Where(x => x.id == fAQDto.id).First(); faq.question = fAQDto.question; faq.answer = fAQDto.answer; entity.SaveChanges(); return(Ok(faq)); }
public ActionResult UpdateFAQ(int id, string question, string answer) { var faqDto = new FAQDto { id = id, question = question, answer = answer }; RestClient restClient = new RestClient(); restClient.BaseUrl = new Uri("http://localhost:54178/"); var restRequest = new RestRequest($"api/FAQ/UpdateFAQ", Method.POST); restRequest.AddObject(faqDto); var result = restClient.Execute(restRequest); TempData["MainPanel"] = "MainPanel"; return(Json(result.Content)); }
public static GetAllResponse GetAll(GetFAQRequest request) { GetAllResponse response = new GetAllResponse(); try { using (FAQDao dao = new FAQDao()) { MFaq[] faqs = dao.GetFaqs(request.page_number, request.row_per_page); if (faqs.Length > 0) { FAQDto[] faqDtos = new FAQDto[faqs.Length]; for (int i = 0; i < faqs.Length; i++) { FAQDto dto = new FAQDto(); dto.faq_id = faqs[i].FaqID; dto.question = faqs[i].Question; dto.answer = faqs[i].Answer; faqDtos[i] = dto; } response.faq_list = faqDtos; response.code = 0; response.has_resource = 1; response.message = MessagesSource.GetMessage("faq.list"); return(response); } else { response.code = 0; response.has_resource = 0; response.message = MessagesSource.GetMessage("faq.list.not.found"); } } } catch (Exception ex) { response.MakeExceptionResponse(ex); } return(response); }
public string SaveFAQ(FAQDto model, string action) { string result = "OK"; try { conn = CreateConnection(); MySqlCommand cmd = new MySqlCommand("PD007_SAVE_FAQ", conn); cmd.CommandType = CommandType.StoredProcedure; MySqlParameterCollection param = cmd.Parameters; param.Clear(); AddSQLParam(param, "@id", Util.NVLInt(model.id)); AddSQLParam(param, "@name", Util.NVLString(model.name)); AddSQLParam(param, "@img_head", Util.NVLString(model.img_head)); AddSQLParam(param, "@img_tail", Util.NVLString(model.img_tail)); AddSQLParam(param, "@detail_hot", Util.NVLString(model.detail_hot)); AddSQLParam(param, "@detail_tail", Util.NVLString(model.detail_tail)); AddSQLParam(param, "@detail_hot_mobile", Util.NVLString(model.detail_hot_mobile)); AddSQLParam(param, "@detail_tail_mobile", Util.NVLString(model.detail_tail_mobile)); AddSQLParam(param, "@faq_order", Util.NVLString(model.faq_order)); AddSQLParam(param, "@member_id", Util.NVLInt(1)); AddSQLParam(param, "@active", Util.NVLInt(model.active)); AddSQLParam(param, "@status", action); conn.Open(); MySqlDataReader read = cmd.ExecuteReader(); while (read.Read()) { result = read.GetString(0).ToString(); } conn.Close(); } catch (Exception e) { result = e.Message.ToString(); } return(result); }
public bool AddFAQ(FAQDto faqdto) { if (faqdto != null) { using (EAharaDB context = new EAharaDB()) { if (faqdto.Id > 0) { var data = context.FAQs.FirstOrDefault(x => x.Id == faqdto.Id); if (data != null) { data.Question = faqdto.Question; data.Answer = faqdto.Answer; context.Entry(data).Property(x => x.Question).IsModified = true; context.Entry(data).Property(x => x.Answer).IsModified = true; context.SaveChanges(); return(true); } return(false); } else { FAQ faq = new FAQ(); faq.Question = faqdto.Question; faq.Answer = faqdto.Answer; faq.IsActive = true; context.FAQs.Add(faq); context.SaveChanges(); return(true); } } } return(false); }