public void updateQuestion(_QuestionViewModel model) { using (ApplicationDbContext context = new ApplicationDbContext()) { Question dbQuestion = context.Questions.Where(x => x.QuestionId == model.QuestionId).FirstOrDefault(); dbQuestion.QuestionBody = model.QuestionBody; dbQuestion.QuestionType = model.QuestionType; dbQuestion.QuestionActive = model.QuestionActive; context.SaveChanges(); } }
public void AddQuestion(_QuestionViewModel model) { using (ApplicationDbContext context = new ApplicationDbContext()) { Question dbQuestion = context.Questions.Create(); dbQuestion.QuestionBody = model.QuestionBody; dbQuestion.QuestionType = model.QuestionType; dbQuestion.CampaignId = model.CampaignId; dbQuestion.IsOn = model.QuestionActive; context.Questions.Add(dbQuestion); context.SaveChanges(); } }
public IHttpActionResult Post(_QuestionViewModel model) { _adapter.AddQuestion(model); return(Ok()); }
public IHttpActionResult Put(_QuestionViewModel model) { _adapter.updateQuestion(model); return(Ok()); }
public IHttpActionResult Get(int Id) { _QuestionViewModel model = _adapter.GetQuestion(Id); return(Ok(model)); }