コード例 #1
0
        public async Task <ActionResult> Edit(FaqDb EditFaq)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    EditFaq.FaqCreateDate   = DateTime.Now;
                    EditFaq.IsActive        = Convert.ToBoolean(EditFaq.Activ);
                    db.Entry(EditFaq).State = EntityState.Modified;
                    await db.SaveChangesAsync();

                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(View(EditFaq));
                }
            }
            catch (Exception)
            {
                return(HttpNotFound());
            }
        }
コード例 #2
0
        public async Task <ActionResult> Create(FaqDb createFaq)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    createFaq.IsActive      = Convert.ToBoolean(createFaq.Activ);
                    createFaq.FaqCreateDate = DateTime.Now;
                    db.Faqs.Add(createFaq);
                    await db.SaveChangesAsync();

                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(View(createFaq));
                }
            }
            catch
            {
                return(HttpNotFound());
            }
        }