TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Andrew Mystery
NA
9
4.4k
C# Choose a return method ActionResult
Nov 17 2015 5:14 PM
Hello all,
I am working on a MVC project, I currently finished three different excel sheets and depending on the type of insurance the user selects a certain default excel sheet format should be used for that insurance.
Currently I can only select one format in the return statement. What I was trying to do is have an if condition depending the string context to decide what excel format to use.
public ActionResult GenerateTripLog(int driverId, int vehicleId, int typeId, int customerId)
{
try
{
var results = (from s in db.usp_TripLog(driverId, vehicleId, typeId, customerId, sDate, eDate)
select s).ToList();
var driver = new DriverRepository(GetCurrentUser()).GetDriver(driverId);
var iType = db.insurancetypes.SingleOrDefault(c => c.id == typeId);
var tenant = GetTenant(GetCurrentUser());
var period = "All";
var driverSignature =
(from s in driver.driveravailabilityevents
where
orderby s.createdon descending
select s.signature).FirstOrDefault();
object[] filterStrs =
{
tenant == null ? "All" : tenant.tenantname,
period,
driver == null || driver.person == null ? "All" : driver.person.fullname,
iType == null ? "All" : iType.name,
driverSignature
};
//THIS IS WHAT I WAS TRYING TO DO THE SELECTION
string insuranceType = Convert.ToString(iType);
if(insuranceType == "FAMILY CARE")
{
return TripLogSpreadsheet(results, filterStrs);
}
else if(insuranceType == "BELLIN")
{
return BELLINLogSpreadsheet(results, filterStrs);
}
//return TripLogSpreadsheet(results, filterStrs);
}
catch (Exception ex)
{
ViewData["errormessage"] = ex.Message;
return View("Error");
}
}
Reply
Answers (
4
)
Dynamicaaly setting textbox width
DNX 87 Error