Exemple #1
0
        public async Task <ActionResult> Create([Bind(Include = "Id,Question")] Models.FAQ fAQ)
        {
            if (ModelState.IsValid)
            {
                fAQ.CreatedOn = DateTime.UtcNow;
                fAQ.CreatedBy = HttpContext.User.Identity.Name;

                fAQ.ModifiedOn = DateTime.UtcNow;
                fAQ.ModifiedBy = HttpContext.User.Identity.Name;

                db.FAQs.Add(fAQ);
                await db.SaveChangesAsync();


                MTCEmailRecipient toRecipient = new MTCEmailRecipient
                {
                    Email = Utilities.GetApplicationSettingValue("LATATraxSupportEmail"),
                    Name  = Utilities.GetApplicationSettingValue("LATATraxSupportName")
                };
                List <MTCEmailRecipient> toRecipients = new List <MTCEmailRecipient> {
                    toRecipient
                };
                EmailManager.SendEmail(toRecipients, "New FAQ", fAQ.Question, null);


                return(RedirectToAction("Index"));
            }

            return(View(fAQ));
        }
Exemple #2
0
        public async Task <ActionResult> Edit([Bind(Include = "Id,Question,CreatedBy,CreatedOn")] Models.FAQ fAQ)
        {
            if (ModelState.IsValid)
            {
                fAQ.ModifiedOn = DateTime.UtcNow;
                fAQ.ModifiedBy = HttpContext.User.Identity.Name;

                db.Entry(fAQ).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(fAQ));
        }
Exemple #3
0
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Models.FAQ fAQ = await db.FAQs.FindAsync(id);

            if (fAQ == null)
            {
                return(HttpNotFound());
            }
            return(View(fAQ));
        }
Exemple #4
0
        public void Update(Models.FAQ item)
        {
            FAQ faqFromDatabase = GetbyID(item.FAQID);

            if (faqFromDatabase != null)
            {
                db.Entry(faqFromDatabase).CurrentValues.SetValues(item);
                db.SaveChanges();
            }
            else
            {
                throw new Exception("FAQ Not Found");
            }
        }
Exemple #5
0
 public void Add(Models.FAQ item)
 {
     db.FAQs.Add(item);
     db.SaveChanges();
 }