public async Task <IActionResult> Post([FromBody] Subject entity) { if (entity == null) { return(HttpBadRequest()); } await _subjectsRepository.Create(entity).ConfigureAwait(false); var controllerName = GetType().Name.Replace("Controller", ""); return(CreatedAtRoute("GetMethod" + controllerName, new { controller = controllerName, id = entity.Id }, entity)); }
public async Task PopulateBase(bool populate) { if (populate != true) { return; } foreach (var student in _students) { await _studentsRepository.Create(student).ConfigureAwait(false); } foreach (var subject in _subjects) { await _subjectsRepository.Create(subject).ConfigureAwait(false); await _subjectsRepository.CreateMarksForSubject(subject.Id, subject.Marks).ConfigureAwait(false); } }