示例#1
0
        public async Task <Faq> AddFaq(Faq faq)
        {
            try
            {
                var _faq = await accountDbContext.Faqs.FirstOrDefaultAsync(p => p.FaqId == faq.FaqId);

                if (_faq != null)
                {
                    _faq.Description = faq.Description;
                    accountDbContext.Faqs.Update(_faq);
                    await accountDbContext.SaveChangesAsync();

                    return(_faq);
                }
                else
                {
                    var faqEntity = await accountDbContext.Faqs.AddAsync(faq);

                    await accountDbContext.SaveChangesAsync();

                    return(faqEntity.Entity);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#2
0
        public List <Faq> SelectAll()
        {
            List <Faq> listFaq = new List <Faq>();
            Faq        faq     = null;

            DataProvider.ExecuteCmd(GetConnection, "dbo.Faq_SelectAll",
                                    inputParamMapper : null
                                    , map : delegate(IDataReader reader, short set)
            {
                faq = new Faq();
                int startingIndex = 0;       //startingOrdinal

                faq.Id            = reader.GetInt32(startingIndex++);
                faq.DateCreated   = reader.GetDateTime(startingIndex++);
                faq.DateModified  = reader.GetDateTime(startingIndex++);
                faq.UserIdCreated = reader.GetString(startingIndex++);
                faq.Question      = reader.GetString(startingIndex++);
                faq.Answer        = reader.GetString(startingIndex++);
                FaqCategory fc    = new FaqCategory();
                fc.Id             = reader.GetSafeInt32(startingIndex++);
                fc.Name           = reader.GetSafeString(startingIndex++);
                faq.FaqCategory   = fc;

                if (faq == null)
                {
                    listFaq = new List <Faq>();
                }

                listFaq.Add(faq);
            }
                                    );

            return(listFaq);
        }
示例#3
0
        protected static List <Task <QueryContainer <CMFAQ> > > GetFAQTask(string q, int timeout, string domain = null)
        {
            Faq faq = new Faq();
            List <Task <QueryContainer <CMFAQ> > > taskList = new List <Task <QueryContainer <CMFAQ> > >();

            if (!string.IsNullOrEmpty(domain))
            {
                taskList.Add(TimedTask.CallWithTimeoutAsync(timeout, () => new Faq().Get(q, domain), null, null));
            }
            else
            {
                List <string> dList = faq.GetDomain();
                if (dList == null)
                {
                    return(taskList);
                }
                DomainMapUnit confine = GetConfigLimit("Library");
                if (confine != null && confine.FAQEX != null && confine.FAQEX.Count > 0)
                {
                    dList = dList.Except(confine.FAQEX).ToList <string>();
                }
                foreach (var d in dList)
                {
                    taskList.Add(TimedTask.CallWithTimeoutAsync(timeout, () => new Faq().Get(q, d), null, null));
                }
            }
            return(taskList);
        }
示例#4
0
        public ActionResult Edit(Faq model)
        {
            try
            {
                // TODO: Add update logic here
                if (!ModelState.IsValid)
                {
                    return(View(model));
                }
                var faq       = _mapper.Map <Faq>(model);
                var isSuccess = _repo.Update(faq);
                if (!isSuccess)
                {
                    ModelState.AddModelError("", "Something Went Wrong!");
                    return(View(model));
                }

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                ModelState.AddModelError("", "Something Went Wrong!");
                return(View(model));
            }
        }
示例#5
0
        private static Faq MapFaq(IDataReader reader)
        {
            int indexCounter = 0;
            Faq faq          = new Faq();

            faq.Id       = reader.GetSafeInt32(indexCounter++);
            faq.Question = reader.GetSafeString(indexCounter++);
            faq.Answer   = reader.GetSafeString(indexCounter++);

            faq.Category      = new TwoColumn();
            faq.Category.Id   = reader.GetSafeInt32(indexCounter++);
            faq.Category.Name = reader.GetSafeString(indexCounter++);

            faq.SortOrder    = reader.GetSafeInt32(indexCounter++);
            faq.DateCreated  = reader.GetSafeDateTime(indexCounter++);
            faq.DateModified = reader.GetSafeDateTime(indexCounter++);

            faq.CreatedBy           = new BaseUserProfile();
            faq.CreatedBy.UserId    = reader.GetSafeInt32(indexCounter++);
            faq.CreatedBy.FirstName = reader.GetSafeString(indexCounter++);
            faq.CreatedBy.LastName  = reader.GetSafeString(indexCounter++);

            faq.ModifiedBy           = new BaseUserProfile();
            faq.ModifiedBy.UserId    = reader.GetSafeInt32(indexCounter++);
            faq.ModifiedBy.FirstName = reader.GetSafeString(indexCounter++);
            faq.ModifiedBy.LastName  = reader.GetSafeString(indexCounter++);

            if (LastColumn == 0)
            {
                LastColumn = indexCounter;
            }

            return(faq);
        }
示例#6
0
 public void Create(Faq faq)
 {
     if (faq != null)
     {
         _context.Faqs.Add(faq);
     }
 }
示例#7
0
        public async Task Faq(CommandContext ctx, string tag)
        {
            Faq faq = await _faqProvider.GetFaqByTag(tag);

            if (faq == null)
            {
                await ctx.RespondAsync("An FAQ under that tag could not be found");

                return;
            }

            DiscordUser creator = await ctx.Client.GetUserAsync(faq.Creator);

            DiscordEmbedBuilder embed = new DiscordEmbedBuilder
            {
                Title       = faq.Tag,
                Description = faq.Content,
                Timestamp   = faq.CreatedDate,
                Color       = new Optional <DiscordColor>(new DiscordColor("#02ABF0")),
                Footer      = new DiscordEmbedBuilder.EmbedFooter
                {
                    IconUrl = string.IsNullOrWhiteSpace(creator.AvatarUrl) ? creator.DefaultAvatarUrl : creator.AvatarUrl,
                    Text    = creator.Username + "#" + creator.Discriminator
                }
            };

            await ctx.RespondAsync(embed : embed);
        }
示例#8
0
        public Faq SelectById(int id)
        {
            Faq faq = null;

            DataProvider.ExecuteCmd(GetConnection, "dbo.Faq_SelectById",
                                    inputParamMapper : delegate(SqlParameterCollection paramCollection)
            {
                paramCollection.AddWithValue("@Id", id);
            }
                                    , map : delegate(IDataReader reader, short set)
            {
                faq = new Faq();
                int startingIndex = 0;

                faq.Id            = reader.GetInt32(startingIndex++);
                faq.DateCreated   = reader.GetDateTime(startingIndex++);
                faq.DateModified  = reader.GetDateTime(startingIndex++);
                faq.UserIdCreated = reader.GetString(startingIndex++);
                faq.Question      = reader.GetString(startingIndex++);
                faq.Answer        = reader.GetString(startingIndex++);
                FaqCategory fc    = new FaqCategory();
                fc.Id             = reader.GetSafeInt32(startingIndex++);
                fc.Name           = reader.GetSafeString(startingIndex++);
                faq.FaqCategory   = fc;
            }
                                    );
            return(faq);
        }
示例#9
0
        public async Task <Response> Insert([FromForm] Faq model)
        {
            Response _objResponse = new Response();

            try
            {
                if (ModelState.IsValid)
                {
                    _context.Add(model);
                    await _context.SaveChangesAsync();

                    _objResponse.Status = "Success";
                    _objResponse.Data   = null;
                }
                else
                {
                    _objResponse.Status = "Validation Error";
                    _objResponse.Data   = null;
                }
            }
            catch (Exception ex)
            {
                _objResponse.Data   = null;
                _objResponse.Status = ex.ToString();
                Console.WriteLine("\nMessage ---\n{0}", ex.ToString());
                Console.WriteLine("\nStackTrace ---\n{0}", ex.StackTrace);
            }
            return(_objResponse);
        }
示例#10
0
 public void UpdateFaq(Faq faqToUpdate, Faq model)
 {
     faqToUpdate.Status   = model.Status;
     faqToUpdate.Question = model.Question;
     faqToUpdate.Answer   = model.Answer;
     _context.SaveChanges();
 }
示例#11
0
        public void Attach_Old_Tag()
        {
            // Assign
            var tags = new[] { "Test" };
            var tag  = new Tag
            {
                Id   = 65,
                Name = "Test",
            };

            var news = new News();
            var faq  = new Faq();

            // Act
            TagHelpers.SetTags <News, NewsTag>(tags, news, new List <Tag> {
                tag
            });
            TagHelpers.SetTags <Faq, FaqTag>(tags, faq, new List <Tag> {
                tag
            });

            // Assert
            Assert.Equal(0, news.NewsTags.Single().NewsId);
            Assert.Equal(0, faq.FaqTags.Single().FaqId);
            Assert.Equal(65, news.NewsTags.Single().Tag.Id);
            Assert.Equal(65, faq.FaqTags.Single().Tag.Id);
        }
示例#12
0
        //
        // GET: /AdminFaq/Edit/5

        public ActionResult Edit(int id)
        {
            Faq model = faq.FindBy(id);

            //ViewBag.model = model;
            return(View(model));
        }
示例#13
0
        public static void Main()
        {
            var documents = new List<Manuscript>();
            var formatter = new FancyFormatter(); // new BackwardsFormatter();

            var faq = new Faq(formatter) { Title = "The Bridge Pattern FAQ" };
            faq.Questions.Add("What is it?", "A design pattern");
            faq.Questions.Add("When do we use it?", "When you need to separate an abstraction from an implementation.");
            documents.Add(faq);

            var book = new Book(formatter)
            {
                Title = "Lots of Patterns",
                Author = "John Sonmez",
                Text = "Blah blah blah..."
            };
            documents.Add(book);

            var paper = new TermPaper(formatter)
            {
                Class = "Design Patterns",
                Student = "Joe N00b",
                Text = "Blah blah blah...",
                References = "GOF"
            };
            documents.Add(paper);

            foreach (var doc in documents)
            {
                doc.Print();
            }

            // Wait for user
            Console.ReadKey();
        }
示例#14
0
        public async Task <Response> Update(int id, [FromForm] Faq model)
        {
            Response _objResponse = new Response();

            try
            {
                if (id != model.FaqId)
                {
                    _objResponse.Status = "No record found";
                    _objResponse.Data   = null;
                }
                else
                {
                    _context.Entry(model).State = EntityState.Modified;
                    await _context.SaveChangesAsync();

                    _objResponse.Status = "Success";
                    _objResponse.Data   = null;
                }
            }
            catch (Exception ex)
            {
                _objResponse.Data   = null;
                _objResponse.Status = ex.ToString();
                Console.WriteLine("\nMessage ---\n{0}", ex.ToString());
                Console.WriteLine("\nStackTrace ---\n{0}", ex.StackTrace);
            }
            return(_objResponse);
        }
示例#15
0
 public ActionResult Create(FormCollection collection)
 {
     try
     {
         // TODO: Add insert logic here
         if (ModelState.IsValid)
         {
             Faq new_model = new Faq();
             new_model.question = Request.Form["question"];
             new_model.answer   = Request.Form["answer"];
             new_model.status   = Convert.ToInt32(Request.Form["status"]);
             new_model.sequence = Request.Form["sequence"];
             new_model.Save();
             return(RedirectToAction("Index"));
         }
         else
         {
             return(View());
         }
     }
     catch
     {
         return(View());
     }
 }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Question,Answer")] Faq faq)
        {
            if (id != faq.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(faq);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FaqExists(faq.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(faq));
        }
示例#17
0
 public Faq EditFaq(Faq faq)
 {
     _context.Faqs.Attach(faq);
     _context.Entry(faq).State = EntityState.Modified;
     _context.SaveChanges();
     return(faq);
 }
        public async Task <int> AddAsync(Faq faq)
        {
            var cmd = QueriesCreatingHelper.CreateQueryInsert(faq);

            cmd += ";SELECT LAST_INSERT_ID();";
            return((await DALHelper.ExecuteQuery <int>(cmd, dbTransaction: DbTransaction, connection: DbConnection)).First());
        }
        public async Task <int> UpdateAsync(Faq faq)
        {
            var cmd = QueriesCreatingHelper.CreateQueryUpdate(faq);
            var rs  = await DALHelper.Execute(cmd, dbTransaction : DbTransaction, connection : DbConnection);

            return(rs == 0 ? -1 : 0);
        }
示例#20
0
 public Faq CreateFaq(Faq model)
 {
     model.AddedDate = DateTime.Now;
     _context.Faqs.Add(model);
     _context.SaveChanges();
     return(model);
 }
示例#21
0
        public ActionResult Update(int FaqID)
        {
            //get faq based on the passed in id and return it
            Faq Faq = db.Faqs.FirstOrDefault(f => f.FaqID == FaqID);

            return(View(Faq));
        }
示例#22
0
        public void FaqService_Delete()
        {
            IFaqService service = this.GetService <IFaqService>();
            Faq         result  = service.GetById(15);

            Assert.IsNotNull(result, "We a null value");
        }
示例#23
0
        public IHttpActionResult UpdateFaq(int id, [FromBody] Faq faq)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != faq.FaqID)
            {
                return(BadRequest());
            }

            db.Entry(faq).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FaqExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#24
0
        protected void BtnSubmit_Click(object sender, EventArgs e)
        {
            Faq f = new Faq();

            if (f.GetFaqById(Tbfaqid.Text) != null)
            {
                LblMsg.Text      = "Record already exists!";
                LblMsg.ForeColor = Color.Red;
            }
            else
            {
                if (ValidateInput())
                {
                    f = new Faq(Tbfaqid.Text, TbQuestion.Text, TbAnswer.Text);
                    int result = f.AddFaq();
                    if (result == 1)
                    {
                        LblMsg.Text      = "Record added successfully!";
                        LblMsg.ForeColor = Color.Green;
                    }
                    else
                    {
                        LblMsg.Text      = "Error in adding record! Inform System Administrator!";
                        LblMsg.ForeColor = Color.Red;
                    }
                }
            }
        }
示例#25
0
        public async Task <IActionResult> PutFaq(long id, Faq f)
        {
            if (id != f.Id)
            {
                return(BadRequest());
            }

            _context.Entry(new Faq
            {
                Id             = f.Id,
                Question       = f.Question,
                Answer         = f.Answer,
                AnswerRendered = Markdown.ToHtml(f.Answer, MarkdownPipelines.All)
            }).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FaqExists(id))
                {
                    return(NotFound());
                }

                throw;
            }
            catch (DbUpdateException ex) when(ex.InnerException is SqlException {
                Number: 2627 or 2601
            })
示例#26
0
 public ActionResult Edit(int id, FormCollection collection)
 {
     try
     {
         // TODO: Add update logic here
         // TODO: Add update logic here
         if (ModelState.IsValid)
         {
             Faq model = faq.FindBy(id);
             model.question = Request.Form["question"];
             model.answer   = Request.Form["answer"];
             model.status   = Convert.ToInt32(Request.Form["status"]);
             model.sequence = Request.Form["sequence"];
             model.Save();
             return(RedirectToAction("Index"));
         }
         else
         {
             return(View());
         }
     }
     catch
     {
         return(View());
     }
 }
示例#27
0
        public int Insert(Faq f)
        {
            // Execute NonQuery return an integer value
            int        result = 0;
            SqlCommand sqlCmd = new SqlCommand();

            //Step 1 -  Define a connection to the database by getting
            //          the connection string from web.config
            string        DBConnect = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
            SqlConnection myConn    = new SqlConnection(DBConnect);

            // Step 2 - Instantiate SqlCommand instance to add record
            //          with INSERT statement
            string sqlStmt = "INSERT INTO Faq (Faqid, qns,ans) " +
                             "VALUES (@paraFaqid,@paraQns, @paraAns)";

            sqlCmd = new SqlCommand(sqlStmt, myConn);

            // Step 3 : Add each parameterised variable with value
            sqlCmd.Parameters.AddWithValue("@paraFaqid", f.FAQID);
            sqlCmd.Parameters.AddWithValue("@paraQns", f.Question);
            sqlCmd.Parameters.AddWithValue("@paraAns", f.Answer);

            // Step 4 Open connection the execute NonQuery of sql command
            myConn.Open();
            result = sqlCmd.ExecuteNonQuery();

            // Step 5 :Close connection
            myConn.Close();

            return(result);
        }
示例#28
0
        public List <Faq> SelectAll()
        {
            //Step 1 -  Define a connection to the database by getting
            //          the connection string from web.config
            string        DBConnect = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
            SqlConnection myConn    = new SqlConnection(DBConnect);

            //Step 2 -  Create a DataAdapter to retrieve data from the database table
            string         sqlStmt = "Select * from Faq";
            SqlDataAdapter da      = new SqlDataAdapter(sqlStmt, myConn);

            //Step 3 -  Create a DataSet to store the data to be retrieved
            DataSet ds = new DataSet();

            //Step 4 -  Use the DataAdapter to fill the DataSet with data retrieved
            da.Fill(ds);

            //Step 5 -  Read data from DataSet to List
            List <Faq> fList   = new List <Faq>();
            int        rec_cnt = ds.Tables[0].Rows.Count;

            for (int i = 0; i < rec_cnt; i++)
            {
                DataRow row   = ds.Tables[0].Rows[i]; // Sql command returns only one record
                string  faqid = row["Faqid"].ToString();
                string  qns   = row["qns"].ToString();
                string  ans   = row["ans"].ToString();


                Faq obj = new Faq(faqid, qns, ans);
                fList.Add(obj);
            }

            return(fList);
        }
        public static List <Faq> GetFaqs(string dataSource)
        {
            List <Faq> faqs = new List <Faq>();

            using (SqliteConnection conn = new SqliteConnection(dataSource))
            {
                conn.Open();

                SqliteCommand cmd = new SqliteCommand("SELECT * from Faq", conn);

                SqliteDataReader rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {
                    var faq = new Faq
                    {
                        Question = rdr["Question"] == DBNull.Value ? "" : (string)rdr["Question"],
                        Answer   = rdr["Answer"] == DBNull.Value ? "" : (string)rdr["Answer"],
                        Id       = rdr["Id"] == DBNull.Value ? -1 : (long)rdr["Id"]
                    };

                    faqs.Add(faq);
                }
            }

            return(faqs);
        }
示例#30
0
        public int Update(Faq f)
        {
            int        result = 0;
            SqlCommand sqlCmd = new SqlCommand();

            string        DBConnect = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
            SqlConnection myConn    = new SqlConnection(DBConnect);

            // Step 2 - Instantiate SqlCommand instance to add record
            //          with INSERT statement
            string sqlStmt = "UPDATE Faq SET Faqid = @paraFaqid, qns = @paraQns, ans = @paraAns where Faqid = @paraFaqid ";

            sqlCmd = new SqlCommand(sqlStmt, myConn);

            // Step 3 : Add each parameterised variable with value
            sqlCmd.Parameters.AddWithValue("@paraFaqid", f.FAQID);
            sqlCmd.Parameters.AddWithValue("@paraQns", f.Question);
            sqlCmd.Parameters.AddWithValue("@paraAns", f.Answer);


            // Step 4 Open connection the execute NonQuery of sql command
            myConn.Open();
            result = sqlCmd.ExecuteNonQuery();

            // Step 5 :Close connection
            myConn.Close();

            return(result);
        }
        public static Faq GetFaq(string dataSource, int id)
        {
            Faq faq = null;

            using (SqliteConnection conn = new SqliteConnection(dataSource))
            {
                conn.Open();

                SqliteCommand cmd = new SqliteCommand("SELECT * FROM Faq WHERE Id = @id", conn);
                cmd.Parameters.AddWithValue("@id", id);

                SqliteDataReader rdr = cmd.ExecuteReader();


                while (rdr.Read())
                {
                    faq = new Faq
                    {
                        Question = rdr["Question"] == DBNull.Value ? "" : (string)rdr["Question"],
                        Answer   = rdr["Answer"] == DBNull.Value ? "" : (string)rdr["Answer"],
                        Id       = rdr["Id"] == DBNull.Value ? -1 : (long)rdr["Id"]
                    };
                }
            }

            return(faq ?? new Faq());
        }
 protected void btnSave_Click(object sender, EventArgs e)
 {
     Faq faq = new Faq();
     faq.FaqID = faqID;
     faq.IsVisible = true;
     faq.Question = txtQuestion.Text;
     faq.Answer = txtAnswer.Text;
     faq.IsVisible = chkIsVisible.Checked;
        int affected= Faq.Save(faq);
        if (affected > 0)
        {
        divMessage.Visible = true;
        lblMessage.Text = "Save successfull";
        resetFields();
        LoadData();
        }
 }
示例#33
0
        public ActionResult Category(string category)
        {
            IEnumerable<Faq> entries;

            if (CurrentCategory == null) {
                entries = new Faq[] { };
            } else {
                entries = Proxy.GetFaqs(
                    new[] { CurrentCategory.Name }.ToList(),
                    null,
                    null,
                    null,
                    TagNames
                );
            }

            return View("~/Views/Home/Category.cshtml", entries);
        }
示例#34
0
 public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) {
     global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType();
     global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence();
     Faq ds = new Faq();
     global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny();
     any1.Namespace = "http://www.w3.org/2001/XMLSchema";
     any1.MinOccurs = new decimal(0);
     any1.MaxOccurs = decimal.MaxValue;
     any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
     sequence.Items.Add(any1);
     global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny();
     any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1";
     any2.MinOccurs = new decimal(1);
     any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
     sequence.Items.Add(any2);
     global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute();
     attribute1.Name = "namespace";
     attribute1.FixedValue = ds.Namespace;
     type.Attributes.Add(attribute1);
     global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute();
     attribute2.Name = "tableTypeName";
     attribute2.FixedValue = "FAQDataTable";
     type.Attributes.Add(attribute2);
     type.Particle = sequence;
     global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
     if (xs.Contains(dsSchema.TargetNamespace)) {
         global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
         global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
         try {
             global::System.Xml.Schema.XmlSchema schema = null;
             dsSchema.Write(s1);
             for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) {
                 schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                 s2.SetLength(0);
                 schema.Write(s2);
                 if ((s1.Length == s2.Length)) {
                     s1.Position = 0;
                     s2.Position = 0;
                     for (; ((s1.Position != s1.Length) 
                                 && (s1.ReadByte() == s2.ReadByte())); ) {
                         ;
                     }
                     if ((s1.Position == s1.Length)) {
                         return type;
                     }
                 }
             }
         }
         finally {
             if ((s1 != null)) {
                 s1.Close();
             }
             if ((s2 != null)) {
                 s2.Close();
             }
         }
     }
     xs.Add(dsSchema);
     return type;
 }
示例#35
0
 public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) {
     Faq ds = new Faq();
     global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType();
     global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence();
     global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny();
     any.Namespace = ds.Namespace;
     sequence.Items.Add(any);
     type.Particle = sequence;
     global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
     if (xs.Contains(dsSchema.TargetNamespace)) {
         global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
         global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
         try {
             global::System.Xml.Schema.XmlSchema schema = null;
             dsSchema.Write(s1);
             for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) {
                 schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                 s2.SetLength(0);
                 schema.Write(s2);
                 if ((s1.Length == s2.Length)) {
                     s1.Position = 0;
                     s2.Position = 0;
                     for (; ((s1.Position != s1.Length) 
                                 && (s1.ReadByte() == s2.ReadByte())); ) {
                         ;
                     }
                     if ((s1.Position == s1.Length)) {
                         return type;
                     }
                 }
             }
         }
         finally {
             if ((s1 != null)) {
                 s1.Close();
             }
             if ((s2 != null)) {
                 s2.Close();
             }
         }
     }
     xs.Add(dsSchema);
     return type;
 }
示例#36
0
 public virtual int Update(Faq dataSet) {
     return this.Adapter.Update(dataSet, "FAQ");
 }
示例#37
0
 public virtual int Update(Faq.FAQDataTable dataTable) {
     return this.Adapter.Update(dataTable);
 }
    internal static int Save(Faq faq)
    {
        using (OleDbCommand cmd = new OleDbCommand())
        {
            try
            {

                string SaveString = "INSERT INTO Faq(IsVisible, Question, Answer) VALUES        (@IsVisible,@Question,@Answer)";
                string UpdateString = "UPDATE Faq SET  IsVisible =@IsVisible, Question =@Question, Answer=@Answer where FaqID=" + faq.FaqID + ";";
                cmd.Parameters.Add(new OleDbParameter("@IsVisible", OleDbType.Boolean, 250));
                cmd.Parameters.Add(new OleDbParameter("@Question", OleDbType.VarChar, 25000));
                cmd.Parameters.Add(new OleDbParameter("@Answer", OleDbType.VarChar, 25000));

                cmd.Parameters["@IsVisible"].Value = faq.IsVisible;
                cmd.Parameters["@Question"].Value = faq.Question;
                cmd.Parameters["@Answer"].Value = faq.Answer;

                if (faq.FaqID == 0)
                {
                    cmd.CommandText = SaveString;
                }
                else { cmd.CommandText = UpdateString; }
                int a = BaseDB.ExecuteNonQuery(cmd);
                return a;
            }
            catch (Exception e)
            {
                throw e;
            }
        }
    }
 public static int Save(Faq faq)
 {
     return FaqData.Save(faq);
 }
示例#40
0
    private void SaveFaq()
    {
        App.Domain.FAQ.FaqManager manager = new App.Domain.FAQ.FaqManager();
        App.Models.FAQ.Faq faq = null;

        if (_FaqID == 0)
            faq = new Faq();
        else
            faq = manager.Get(_FaqID);

        if (faq != null)
        {
            faq.Question = txtQuestion.Text.Trim();
            faq.Answer = txtAnswer.Text.Trim();
            faq.FaqCatID = Convert.ToInt32(ddlFaqCategory.SelectedValue);
            faq.TimeStamp = DateTime.Now;
            faq.EnteredBy = SessionCache.CurrentUser.Username;

            //Save the Object
            manager.SaveOrUpdate(faq);
        }
    }