asp.net mvc - Implement Dependency injection in MVC (Webservices) -
in project, iám calling code repository mvc controllers. repository have function work exchange server, echange managed api.
now, want implement dependency injection in project.
i can not figure out in code must modified call repository dependency injection
can ?
her repository:
public class exchangeews : iexchangeews { public list<datetime> getavaliablebookingdays(exchangeservice service, list<advisor> advisors, datetime startdate, datetime enddate, int num_appt) { list<datetime> avaliablebookingdays = new list<datetime>(); foreach (advisor adobj in advisors) { // user's calendar folder calendarfolder calendar = calendarfolder.bind(service, new folderid(wellknownfoldername.calendar, adobj.emailaddress), new propertyset()); // appointments retrieve.(calendarview return recurring appointment) calendarview cview = new calendarview(startdate, enddate, num_appt); // def properties returned cview.propertyset = new propertyset(appointmentschema.start, appointmentschema.isrecurring, appointmentschema.legacyfreebusystatus, appointmentschema.subject, appointmentschema.appointmenttype); finditemsresults<appointment> appointments = calendar.findappointments(cview); if (appointments.count() > 0) { avaliablebookingdays.addrange((from appobj in appointments (appobj.appointmenttype == appointmenttype.occurrence || appobj.appointmenttype == appointmenttype.exception) && appobj.legacyfreebusystatus == legacyfreebusystatus.free && appobj.subject.tolower().contains("kwodkowdkowdow") select appobj.start).tolist()); } } list<datetime> distinctdates = avaliablebookingdays .groupby(day => day.date) .select(g => g.first()) .tolist(); return distinctdates; } }
here controller:
public class homecontroller : controller { public actionresult service() { list<advisor> adv = new list<advisor>() { new advisor { id = 1, location = "london", emailaddress = "dwded@dd.dk", name = "loppe" } }; exchangeservice service= exchangeews.getexchangeconnection("xxxx@jj.com", password); exchangeews x = new exchangeews(); x.getavaliablebookingdays(service, adv, datetime.now, datetime.now.adddays(45), 20); return view(); }
Comments
Post a Comment