public bool Save(SaveQuestionIutputDto inputQuestion) { QuesList ques = null; if (inputQuestion.ID > 0) { ques = this.questionRepository.FindBy(x => x.ID == inputQuestion.ID).FirstOrDefault(); } if (ques == null) { ques = new QuesList(); } ques.Question = inputQuestion.Question; ques.Answer = Cmn.GetCompressed(inputQuestion.Answer); ques.AnswerLength = inputQuestion.Answer.Length; ques.Language = inputQuestion.Language; ques.Type = inputQuestion.Type; ques.Reviewed = 1; if (inputQuestion.ID == 0) { this.questionRepository.Add(ques); } else { this.questionRepository.Update(ques); } this.unitOfWork.Commit(); return(true); }
public bool Delete(int ID) { QuesList ques = this.questionRepository.FindBy(x => x.ID == ID).FirstOrDefault(); if (ques != null) { this.questionRepository.Delete(ques); this.unitOfWork.Commit(); return(true); } return(false); }