public bool ShopStart(DateTime date, string shopId) { ReportDbContext reportDb = ReportDbContext.Create(); date = date.Date; SaleReport report = reportDb.SaleReports.Where(x => x.ShopId == shopId).FirstOrDefault(x => x.Date == date); if (report == null) { report = new SaleReport { SaleType = SaleType.All }; this.SetDefaults(report, shopId, date); var dealerReport = new SaleReport { SaleType = SaleType.DealerSale }; this.SetDefaults(dealerReport, shopId, date); var customerReport = new SaleReport { SaleType = SaleType.CustomerSale }; this.SetDefaults(customerReport, shopId, date); var collection = new List <SaleReport>() { report, dealerReport, customerReport }; reportDb.SaleReports.AddRange(collection); int i = reportDb.SaveChanges(); return(i > 0); } return(true); }