public async Task <ApiResponse <Subject> > CreateSubject(SubjectDto subjectDto) { var response = new ApiResponse <Subject>(); try { //check subject Exists var isExistSubject = await _subjectRepository.CountAsync(i => i.Name == subjectDto.Name); if (isExistSubject != 0) { response.Success = false; response.Errors.Add("Subject Already Exists"); return(response); } var id = Guid.NewGuid(); //create new subject var subject = Mapper.Map <Subject>(subjectDto); subject.Id = id; //subject.CreatedBy = subject.Id; subject.CreatedDate = DateTime.Now; //subject.Roles = subjectRoles; subject.IsActive = true; await _subjectRepository.AddAsyn(subject); response.Success = true; } catch (Exception ex) { response.Success = false; response.Errors.Add(ex.Message); } return(response); }