private void Seed_Assessments() { if (!_context.Assessments.Any()) { var testAssessment = new Assessment() { Code = "testA", Description = "DescriptionA", Level = "H", Marks = 40, Timing = "30 minutes", Percentage = (decimal) 0.40, Exampapers = new List<Exampaper>() { new Exampaper() {Code = "testA", Level = "H", Year = 2015}, new Exampaper() {Code = "testA", Level = "H", Year = 2014}, new Exampaper() {Code = "testA", Level = "H", Year = 2013}, new Exampaper() {Code = "testA", Level = "H", Year = 2012}, new Exampaper() {Code = "testA", Level = "H", Year = 2011} } }; _context.Assessments.Add(testAssessment); _context.Exampapers.AddRange(testAssessment.Exampapers); _context.SaveChanges(); } }
public void AddAssessment(Assessment newAssessment) { try { _context.Add(newAssessment); } catch (Exception ex) { _logger.LogError("Cannot get data", ex); } }
public void DeleteAssessment(Assessment assessment) { try { _context.Assessments.Remove(assessment); } catch (Exception ex) { _logger.LogError("Cannot update Assessment", ex); } }
public void UpdateAssessment(Assessment updatedAssessment) { try { _context.Assessments.Update(updatedAssessment); } catch (Exception ex) { _logger.LogError("Cannot update Assessment", ex); } }