예제 #1
0
        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));
        }
예제 #2
0
        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());
            }
        }