public TaskLog Create(TaskLog item) { if (item.IsValid()) { try { db.TaskLogs.Add(item); db.SaveChanges(); if (item.TaskID.HasValue) { item.Task = db.Tasks.Where(t => t.ID == item.TaskID.Value).Single(); } MarkNotIsNew(item); return(item); } catch (Exception ex) { db.TaskLogs.Remove(item); throw ex; } } else { throw new Exception("TaskLog is invalid"); } }
public TaskLog Update(TaskLog item) { TaskLog updated = FetchAndUpdate(item); if (updated.IsValid()) { try { db.SaveChanges(); return(updated); } catch (Exception ex) { throw ex; } } else { throw new Exception("Requirement is invalid"); } }