public void Update(Models.ActionLog entity) { var agencyInDatabase = db.Agencies.Find(entity.ActionLogID); if (agencyInDatabase == null) { Add(entity); } else { db.Entry(agencyInDatabase).CurrentValues.SetValues(entity); } }
public void Add(Models.ActionLog entity) { if (entity.Actions == null) { entity.Actions = db.Actions .Where(a => entity.ActionIDs.Contains(a.ActionID)).ToList(); } if (entity.MetricTypes == null) { entity.MetricTypes = db.MetricTypes .Where(a => entity.MetricTypeIDs.Contains(a.MetricID)).ToList(); } db.ActionLogs.Add(entity); db.SaveChanges(); }