public ActionResult Create([Bind(Include = "Name, Sex, DateBorn, Age, FormId")] FamilyVM familyVM) { if (ModelState.IsValid) { FamilyDTO familyDTO = Mapper.Map <FamilyDTO>(familyVM); //int questionId = QuestionService.AddAndGetId(questionDTO); FamilyService.Add(familyDTO); return(RedirectToAction("Index")); } ViewBag.FormId = GetFormIdSelectList(familyVM.FormId); return(View(familyVM)); }
public async Task <IActionResult> CreateFamily([FromBody] FamilyModel familyModel) { if (familyModel == null) { return(BadRequest()); } try { var userId = GetCurrentUserId(); await _familyService.Add(userId, familyModel.Name, familyModel.Description); return(Ok()); } catch (Exception ex) { _logger.LogError(ex.Message); return(BadRequest()); } }