asp.net mvc 5.1 - mvc5 N tier architecture -
asp.net mvc 5.1 - mvc5 N tier architecture -
i developing mvc app next n tier structure:
dataaccess repository models businesslogic
in businesslogic folder have interface iclinicbusiness
, class clinicbusiness
interfaces iclinicbusiness.
the clinicbusiness class follows:
public void addclinic(clinic c) { var cr = new clinicrepository(); var clinc = new clinic(); if (c != null) { clinc.clinicname = c.clinicname; clinc.cliniclocation = c.cliniclocation; } cr.insertclinic(c); cr.save(); } }
the clinicbusiness
class implements method repository class library eg. insertclinic();
public clinicrepository() { } public clinicrepository(datacontext clinics) { this.clinic = clinics; } public ienumerable<clinic> getclinics() { homecoming clinic.clinics.tolist(); } public clinic getclinicbyid(int clinicid) { homecoming clinic.clinics.find(clinicid); } public void insertclinic(clinic c) { clinic.clinics.add(c); }
in controller have action
public actionresult createclinic(clinic c) { var clinicbusiness = new clinicrepository(); homecoming view(clinicbusiness.insertclinic(c)); }
i next error cannot convert 'void' 'object'
can please guide me?
depending on requirements, think want alter repository insertclinic
method to
public clinic insertclinic(clinic c) { clinic.clinics.add(c); homecoming c; }
or alter action to
public actionresult createclinic(clinic c) { var clinicbusiness = new clinicrepository(); clinicbusiness.insertclinic(c) homecoming view(c); }
again, depends on trying accomplish , view model.
asp.net-mvc-5.1
Comments
Post a Comment