how to add if condition in the editor method on controller, .net
how to add if condition in the editor method on controller, .net

how to add if condition in the editor method on controller, .net
[AcceptVerbs(HttpVerbs.Get | HttpVerbs.Post)]
public ActionResult GetDataTrip(Enums.JsonSortType type, int id)
{
var settings = Properties.Settings.Default;
var formData = HttpContext.ApplicationInstance.Context.Request;
using (var db = new Database(settings.DbType, settings.DbConnection))
{
var response = new Editor(db, "Trip", "Trip_Id")
.Model<Model.Trip>("Trip")
.Field(new Field("Trip.Trip_Id")
.Validator(Validation.Numeric())
)
.Field(new Field("Trip.Trip_Name")
.Validator(Validation.Unique(new ValidationOpts
{
Message = "שם המסלול קיים, השם חייב להיות יחודי"
}))
.Validator(Validation.MaxLen(50))
)
.Field(new Field("Trip.Trip_DaysNum")
.Options(() => getDayList()
)
.Validator(Validation.Numeric())
)
.Field(new Field("Trip.Requires_Flights", typeof(bool))
)
.MJoin(new MJoin("Countries")
.Link("Trip.Trip_Id", "Trip_Countries.Trip_Id")
.Link("Countries.Country_Id", "Trip_Countries.Country_Id")
.Model<Model.Countries>()
.Order("Countries.Country_Id")
.Field(new Field("Country_Id")
.Options("Countries", "Country_Id", "Country_Name")
))
.MJoin(new MJoin("DayTrip")
.Link("Trip.Trip_Id", "Trip_DayTrip.Trip_Id")
.Link("DayTrip.DayTrip_Id", "Trip_DayTrip.DayTrip_Id")
.Model<Model.DayTrip>()
.Order("DayTrip.DayTrip_Id")
.Field(new Field("DayTrip_Id")
.Options("DayTrip", "DayTrip_Id", "TripName")
))
.Process(formData)
.Data();
return Json(response, JsonRequestBehavior.AllowGet);
}
}
i have a type and id, and based on the type i want to return the correct result with where, but if i add if statement always i didn't get the data, and always get
"Uncaught TypeError: Cannot read property 'length' of undefined"
This discussion has been closed.
Answers
What is the condition you want to use? Assuming you always want to run the Editor code, but optionally add an
Where()
statement, you could do:Allan