public ActionResult SurveyQuestionCreate(SurveyViewModel surveyViewModel, SurveyQuestionCreateViewModel surveyQuestionCreateViewModel) { var model = new SurveyQuestionCreateViewModel(); var personId = HttpContext.Session.GetInt32("personId"); if (surveyViewModel.Survey != null) { surveyViewModel.Survey.StartDate = DateTime.Now; surveyViewModel.Survey.EndDate = DateTime.Now; surveyViewModel.Survey.ManagerId = (int)personId;//şuanlık //personId surveyViewModel.Survey.IsOpen = true; _surveyService.Add(surveyViewModel.Survey); } if (surveyQuestionCreateViewModel.Question == null) { model.SurveyId = surveyViewModel.Survey.Id; model.Questions = _questionService.GetBySurveyId(surveyViewModel.Survey.Id); model.QuestionResponseOptions = _questionOptionService.GetAll(); } else { surveyQuestionCreateViewModel.Question.QuestionTypeId = 1; //Soru türü için surveyQuestionCreateViewModel.Question.SurveyId = surveyQuestionCreateViewModel.SurveyId; _questionService.Add(surveyQuestionCreateViewModel.Question); model.SurveyId = surveyQuestionCreateViewModel.SurveyId; model.Questions = _questionService.GetBySurveyId(surveyQuestionCreateViewModel.SurveyId); model.QuestionResponseOptions = _questionOptionService.GetAll(); } return(View(model)); }
public async Task <IHttpActionResult> Post(Models.SurveyModel survey) { if (!ModelState.IsValid) { return(BadRequest("Invalid Data")); } try { var dto = survey.MapObject(); dto.CreateDateTime = DateTime.Now; await surveyService.Add(dto); } catch (InvalidOperaionException ex) { return(BadRequest(ex.Message)); } return(Ok()); }
public IHttpActionResult Create([FromBody] SurveyDTO surveyDTO) { if (surveyDTO == null) { return(BadRequest("Survey is null")); } Survey survey = new Survey { Title = surveyDTO.Title, Description = surveyDTO.Description }; int id = _surveyService.Add(survey); if (id <= 0) { return(BadRequest("Unable to create survey")); } var payload = new { SurveyId = id }; return(Ok()); }
public IActionResult AddItem(Survey component) { _surveyService.Add(component, User.Identity.Name); return(Surveys()); }