public void UpdateHomework(HomeworkDTO hw) { var homew = _homeworkRepo.Get(c => c.HomeworkId == hw.HomeworkId); if (homew == null) throw new Exception("Homework not found."); homew.Text = hw.Text; homew.Score = hw.Score; _homeworkRepo.SaveChanges(); }
public void CreateHomework(HomeworkDTO dtoHw) { var h = Mapper.Map<Homework>(dtoHw); h.Module = _moduleRepo.Get(u => u.ModuleId == dtoHw.Module.ModuleId); _homeworkRepo.Add(h); }