public async Task <ActionResult> Create(SubjectViewModel subject, string StudyPCodeStr) { if (!ModelState.IsValid) { return(new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest, "FullError")); } //Valid Subjec's code bool exitCode = this._serviceSubject.ExitCode(subject.Code); if (exitCode) { return(new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest, "CodeExit")); } //Create Subject var subjectToSave = subject.GenericConvert <domain.Subject>(); subjectToSave.StudyPlanFK = StudyPCodeStr; subjectToSave.Created = DateTime.Now; subjectToSave.Status = Helpers.Status.Active; _serviceSubject.Add(subjectToSave); var listOfSubjects = await _serviceSubject.GetAllSubjectByStudyPlanAsync(StudyPCodeStr); Message msg = new Message() { Code = 1, Messages = "Ok", list = listOfSubjects.GenericConvertList <vm.SubjectViewModel>() }; return(Json(ToJSON <Message>(msg), JsonRequestBehavior.AllowGet)); }