All related data from another table does not show on my application ASP.NET Core -


this question has answer here:

i trying create online event tracker. have class date

public class day {     [key]     public string daycounter { get; set; }      public datetime daydate { get; set; }      public list<event> events { get; set; } } 

and event class

public class event {     public int eventid { get; set; }     public datetime starttime { get; set; }     public datetime endtime { get; set; }     public string activity { get; set; }     public string daycounter { get; set; }     public day day { get; set; } } 

i have used code first , created 2 tables days , events in azure. have created api controller below

[enablecors("corspolicy")]  [route("api/[controller]")] public class daysapicontroller : controller {     public applicationdbcontext _context;     public daysapicontroller(applicationdbcontext context)     {         _context = context;     }     // get: api/values      [httpget]     public jsonresult get()     {         var days= json(_context.days.orderby(d=>d.daydate).include(e=>e.events).tolist());         return (days);      }      // api/values/5     [httpget("{id}")]     public day get(string id)     {         return _context.days.include(e => e.events).firstordefault();     } } 

when try navigate localhost/api/daysapi not result or 1 day 1 event included. did go wrong? using vs 2015 , startup.cs below:

public void configureservices(iservicecollection services) {     var connection = configuration["data:defaultconnection:connectionstring"];     // add framework services.     services.adddbcontext<applicationdbcontext>(options =>         options.usesqlserver(connection));      services.addidentity<applicationuser, identityrole>()         .addentityframeworkstores<applicationdbcontext>()         .adddefaulttokenproviders();     services.addcors(options =>     {         options.addpolicy("corspolicy",             builder => builder.allowanyorigin()             .allowanymethod()             .allowanyheader()             .allowcredentials());     });      services.addmvc();      // add application services.     services.addtransient<iemailsender, authmessagesender>();     services.addtransient<ismssender, authmessagesender>(); } 

i have seeded database below

public static void initial(applicationdbcontext db)     {         if (db.days.any())         {             return;         }         db.days.add(new day         {             daycounter = (convert.todatetime("2017/04/04")).dayofyear.tostring(),             daydate = convert.todatetime("2017/04/04")          });         db.days.add(new day         {             daycounter = (convert.todatetime("2017/04/05")).dayofyear.tostring(),             daydate = convert.todatetime("2017/04/05")         });         db.days.add(new day         {             daycounter = (convert.todatetime("2017/04/07")).dayofyear.tostring(),             daydate = convert.todatetime("2017/04/07")         });         db.days.add(new day         {             daycounter = (convert.todatetime("2017/04/08")).dayofyear.tostring(),             daydate = convert.todatetime("2017/04/08")         });         db.days.add(new day         {             daycounter = (convert.todatetime("2017/04/09")).dayofyear.tostring(),             daydate = convert.todatetime("2017/04/09")         });         db.savechanges();           db.events.add(new event         {             starttime = convert.todatetime("2017/04/04 08:30 am"),             endtime = convert.todatetime("2017/04/04 10:30 am"),             activity = "senior’s  golf tournament",             daycounter = db.days.find(convert.todatetime("2017/04/04").dayofyear.tostring()).daycounter          });         db.events.add(new event         {             starttime = convert.todatetime("2017/04/05 08:30 am"),             endtime = convert.todatetime("2017/04/05 10:30 am"),             activity = "leadership general assembly meeting",             daycounter = db.days.find(convert.todatetime("2017/04/05").dayofyear.tostring()).daycounter          });         db.events.add(new event         {             starttime = convert.todatetime("2017/04/07 05:30 pm"),             endtime = convert.todatetime("2017/04/07 07:15 pm"),             activity = "youth bowling tournament",             daycounter = db.days.find(convert.todatetime("2017/04/05").dayofyear.tostring()).daycounter          });         db.events.add(new event         {             starttime = convert.todatetime("2017/04/07 07:00 pm"),             endtime = convert.todatetime("2017/04/07 08:00 pm"),             activity = "young ladies cooking lessons",             daycounter = db.days.find(convert.todatetime("2017/04/07").dayofyear.tostring()).daycounter          });         db.events.add(new event         {             starttime = convert.todatetime("2017/04/08  08:30 am"),             endtime = convert.todatetime("2017/04/08   10:30 am"),             activity = "youth craft lessons",             daycounter = db.days.find(convert.todatetime("2017/04/08").dayofyear.tostring()).daycounter          });         db.events.add(new event         {             starttime = convert.todatetime("2017/04/08 10:30 am"),             endtime = convert.todatetime("2017/04/08 12:00 pm"),             activity = "youth choir practice",             daycounter = db.days.find(convert.todatetime("2017/04/08").dayofyear.tostring()).daycounter          });         db.events.add(new event         {             starttime = convert.todatetime("2017/04/08 12:00 pm"),             endtime = convert.todatetime("2017/04/08 01:30 pm"),             activity = "lunch",             daycounter = db.days.find(convert.todatetime("2017/04/08").dayofyear.tostring()).daycounter          });         db.events.add(new event         {             starttime = convert.todatetime("2017/04/09  07:30 am"),             endtime = convert.todatetime("2017/04/09   08:30 am"),             activity = "pancake breakfast",             daycounter = db.days.find(convert.todatetime("2017/04/09").dayofyear.tostring()).daycounter          });         db.events.add(new event         {             starttime = convert.todatetime("2017/04/09  08:30 am"),             endtime = convert.todatetime("2017/04/09   10:30 am"),             activity = "swimming lessons youth",             daycounter = db.days.find(convert.todatetime("2017/04/09").dayofyear.tostring()).daycounter          });         db.events.add(new event         {             starttime = convert.todatetime("2017/04/09  08:30 am"),             endtime = convert.todatetime("2017/04/09   10:30 am"),             activity = "swimming exercise parents",             daycounter = db.days.find(convert.todatetime("2017/04/09").dayofyear.tostring()).daycounter          });         db.events.add(new event         {             starttime = convert.todatetime("2017/04/09  10:30 am"),             endtime = convert.todatetime("2017/04/09   12:00 pm"),             activity = "bingo tournament",             daycounter = db.days.find(convert.todatetime("2017/04/09").dayofyear.tostring()).daycounter          });         db.events.add(new event         {             starttime = convert.todatetime("2017/04/09  12:00 pm"),             endtime = convert.todatetime("2017/04/09   01:00 pm"),             activity = "bbq lunch",             daycounter = db.days.find(convert.todatetime("2017/04/09").dayofyear.tostring()).daycounter          });         db.events.add(new event         {             starttime = convert.todatetime("2017/04/09  01:00 pm"),             endtime = convert.todatetime("2017/04/09   06:00 pm"),             activity = "garage sale",             daycounter = db.days.find(convert.todatetime("2017/04/09").dayofyear.tostring()).daycounter          });         db.savechanges();     } 

the result when events table not included on firefox below:

[{"daycounter":"94","daydate":"2017-04-04t00:00:00","events":null},{"daycounter":"95","daydate":"2017-04-05t00:00:00","events":null},{"daycounter":"97","daydate":"2017-04-07t00:00:00","events":null},{"daycounter":"98","daydate":"2017-04-08t00:00:00","events":null},{"daycounter":"99","daydate":"2017-04-09t00:00:00","events":null}] 

when events table included firefox shows quick changes server not found message. chrome sign on top keeps turning , console shows failed load resource: net::err_connection_reset error message.

i have found answer after searching entire stack on flow. question has been asked , answered herestackoverflow question


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -