public bool Create(FAQModelDAL Question) { try { using (var DBConnection = new DB()) { DBConnection.FAQs.Add(Question); DBConnection.SaveChanges(); Loggings.GeneralLog("Created User Question with ID: " + Question.ID); return(true); } } catch (Exception ex) { var logg = new LoggTypeDAL() { EventType = "Exception", Created_By = "System", LogMessage = ex.ToString(), Created_date = DateTime.Now }; Loggings.LogToBoth(logg); return(false); } }
public bool DownVote(int IDin) { try { using (var DBConnection = new DB()) { var question = new FAQModelDAL(); question.ID = IDin; var questionFound = DBConnection.FAQs.Find(question.ID); if (questionFound == null) { Loggings.GeneralLog("Could not find Question with ID: " + question.ID); return(false); } questionFound.Score = questionFound.Score - 1; DBConnection.SaveChanges(); Loggings.GeneralLog("Updated Question with ID: " + question.ID); return(true); } } catch (Exception ex) { var logg = new LoggTypeDAL() { EventType = "Exception", Created_By = "System", LogMessage = ex.ToString(), Created_date = DateTime.Now }; Loggings.LogToBoth(logg); return(false); } }
public ActionResult CreateQuestion(FAQModelDAL model) { if (model.Question.Length > 0 && model.Question.Length != null) { var newQuestion = new FAQModelDAL { Question = model.Question, Answer = "", UserSubmitted = true, Score = 0 }; FaqLogic.Create(newQuestion); } return(RedirectToRoute(new { controller = "FAQ", action = "Index" })); }
public bool Create(FAQModelDAL Question) { var result = FaqDal.Create(Question); return(result); }