public static HttpResponseMessage addQuestion(Entities.Question question) { Entities.Question q = new Entities.Question(); try { q.Answer = question.Answer; q.QueTopicId = question.QueTopicId; q.QueUserId = question.QueUserId; q.Question1 = question.Question1; db.Question.Add(Entities.Question.QuestionDAL(q)); db.SaveChanges(); return(new HttpResponseMessage(HttpStatusCode.OK) { }); } catch (Exception e) { BL.SendMail.SendEmail(e.ToString(), e.Message, ""); BL.WriteLogError.WriteLogErrors(e.Message); return(new HttpResponseMessage(HttpStatusCode.BadRequest) { }); } }
public static List <Entities.Question> addAnswerfromRav(Entities.Question question) { try { List <Entities.Question> questions = new List <Question>(); db.Question.Add(Entities.Question.QuestionDAL(question)); db.SaveChanges(); foreach (var item in db.Question.ToList()) { questions.Add(Entities.Question.QuestionEntities(item)); } return(questions); } catch (Exception e) { BL.SendMail.SendEmail(e.ToString(), e.Message, ""); BL.WriteLogError.WriteLogErrors(e.Message); return(null); } }
public void AddForm(FormDetailDTO formDTO) { //add form CultureInfo provider = CultureInfo.InvariantCulture; // string format = "ddd MMM d HH:mm:ss GMT"; Form form = new Form() { CreatedDate = DateTime.Now, Deadline = DateTime.Now.AddDays(7 * Int32.Parse(formDTO.Deadline)), State = formDTO.State, Title = formDTO.Title }; Question q; Answer a; form.CategoryID = GetCategoryID(formDTO.Category); form.UserID = GetUserID(formDTO.Username); _dataAccess.FormRepository.Add(form); //add questions int formID = GetFormID(form.Title, form.UserID, form.CreatedDate); //preiau id-ul formului int questionID; foreach (QuestionDTO questionDTO in formDTO.Questions) { q = new Question(); q.FormID = form.FormID; q.Content = questionDTO.Question; q.NrVotes = 0; _dataAccess.QuestionRepository.Add(q); //add answer questionID = GetQuestionID(q.Content, formID); foreach (AnswerDTO answerDTO in questionDTO.Answers) { a = new Answer(); a.Content = answerDTO.Answer; a.NrVotes = 0; a.QuestionID = questionID; _dataAccess.AnswerRepository.Add(a); } } }
public IHttpActionResult addAnswerfromRav([FromBody] Entities.Question question) { return(Ok(BL.ManagerLogic.addAnswerfromRav(question))); }
public IHttpActionResult addQuestion([FromBody] Entities.Question question) { return(Ok(BL.DataBaseLogic.addQuestion(question))); }