/// <summary> /// Updates the given person /// </summary> /// <param name="item">Person to update</param> /// <returns>True, if person could be updated succesful, false otherwise</returns> internal bool UpdatePerson(IPerson item) { if (item == null) { throw new ArgumentNullException(nameof(item)); } if (!ContainsPerson(item)) { AddPerson(item); return true; } using (OwlCalcDatabase dbContext = new OwlCalcDatabase()) { Person nation = dbContext.Persons.FirstOrDefault(x => x.Id == item.Id); dbContext.Entry(nation).CurrentValues.SetValues(item); dbContext.SaveChanges(); } return true; }
/// <summary> /// Updates the given company /// </summary> /// <param name="item">Company to update</param> /// <returns>True, if company could be updated succesful, false otherwise</returns> internal bool UpdateCompany(ICompany item) { if (item == null) { throw new ArgumentNullException(nameof(item)); } if (!ContainsCompany(item)) { AddCompany(item); return true; } using (OwlCalcDatabase dbContext = new OwlCalcDatabase()) { Company company = dbContext.Companies.FirstOrDefault(x => x.Id == item.Id); dbContext.Entry(company).CurrentValues.SetValues(item); dbContext.SaveChanges(); } return true; }