public static void Create(TaskLogDto dto) { using (var db = new MainDBModelContainer()) { var entity = TaskLogMapper.DtoToEntity(dto, db); db.TaskLogSet.Add(entity); db.SaveChanges(); } }
public static void Update(TaskLogDto dto) { using (var db = new MainDBModelContainer()) { var newData = TaskLogMapper.DtoToEntity(dto, db); var oldData = db.TaskLogSet.Find(dto.Id); if (oldData != null) { oldData.Event = newData.Event; oldData.EntryDate = newData.EntryDate; oldData.Task = newData.Task; db.SaveChanges(); } else { throw new ElementNotFoundException(); } } }