private Company Add(CompanyModel model) { using (var context = _contextFactory.CreateContext()) { var company = model.MapTo <Company>(); company.CreatedOn = DateTime.Now; var billingAddress = company.Addresses.FirstOrDefault(a => a.IsBilling); billingAddress.CreatedOn = DateTime.Now; context.Add(company); context.SaveChanges(); return(company); } }