Exemplo n.º 1
0
        public async Task <ActionResult <Subject> > Create([FromForm] SubjectViewModel subjectViewModel)
        {
            if (subjectViewModel == null)
            {
                return(NoContent());
            }
            if (ModelState.IsValid)
            {
                Subject subject = SubjectViewModel.MapSubjectViewModelToEntity(subjectViewModel);
                subject.UserId     = _currentUserService.UserId;
                subject.ModifiedBy = subject.UserId;
                _logger.LogInformation(subject.UserId);
                var createdResult = await _subjectService.CreateAsync(subject);

                if (createdResult.Item2)
                {
                    return(Ok("Successfully created Subject!"));
                }
                return(BadRequest("Something went wrong when create Subject."));
            }
            return(BadRequest(ModelState));
        }