コード例 #1
0
ファイル: Configuration.cs プロジェクト: LeAnhNhan76/TeduShop
 private void CreateContactDetail(TeduShopDbContext context)
 {
     if (!context.ContactDetails.Any())
     {
         try
         {
             var contactDetail = new TeduShop.Model.Models.ContactDetail()
             {
                 Name    = "Shop thời trang TEDU",
                 Address = "23 Nguyễn Thị Huỳnh, phường 8, quận Phú Nhuận",
                 Email   = "*****@*****.**",
                 Lat     = 10.7969016,
                 Lng     = 106.6741883,
                 Phone   = "0339700824",
                 Website = "http://tedu.com.vn",
                 Other   = "",
                 Status  = true
             };
             context.ContactDetails.Add(contactDetail);
             context.SaveChanges();
         }
         catch (DbEntityValidationException ex)
         {
             foreach (var eve in ex.EntityValidationErrors)
             {
                 Trace.WriteLine($"Entity of type \"{eve.Entry.Entity.GetType().Name}\" in state \"{eve.Entry.State}\" has the following validation error.");
                 foreach (var ve in eve.ValidationErrors)
                 {
                     Trace.WriteLine($"- Property: \"{ve.PropertyName}\", Error: \"{ve.ErrorMessage}\"");
                 }
             }
         }
     }
 }
コード例 #2
0
ファイル: Configuration.cs プロジェクト: tndm01/APIsNoDepTrai
 private void CreateContactDetail(TeduShopDbContext context)
 {
     if (context.ContactDetails.Count() == 0)
     {
         try
         {
             var contactDetail = new TeduShop.Model.Models.ContactDetail()
             {
                 Name    = "Shop th?i trang TEDU",
                 Address = "Ngõ 77 Xuân La",
                 Email   = "*****@*****.**",
                 Lat     = 21.0633645,
                 Lng     = 105.8053274,
                 Phone   = "095423233",
                 Website = "http://tedu.com.vn",
                 Other   = "",
                 Status  = true
             };
             context.ContactDetails.Add(contactDetail);
             context.SaveChanges();
         }
         catch (DbEntityValidationException ex)
         {
             foreach (var eve in ex.EntityValidationErrors)
             {
                 Trace.WriteLine($"Entity of type \"{eve.Entry.Entity.GetType().Name}\" in state \"{eve.Entry.State}\" has the following validation error.");
                 foreach (var ve in eve.ValidationErrors)
                 {
                     Trace.WriteLine($"- Property: \"{ve.PropertyName}\", Error: \"{ve.ErrorMessage}\"");
                 }
             }
         }
     }
 }