Foreign Primary Key Work In Controller with Editor Action Method

Foreign Primary Key Work In Controller with Editor Action Method

mftadminmftadmin Posts: 4Questions: 1Answers: 0

var test = _context.CIS_Currencies.Where(x => x.currency_Desc == site).FirstOrDefault();
var dbType = Environment.GetEnvironmentVariable("DBTYPE");
var dbConnection = Environment.GetEnvironmentVariable("DBCONNECTION");

        using (var db = new Database(dbType, dbConnection))
        {
            var response = new Editor(db, "MKT_Outstandings")
                .Model<MKT_Outstanding>()
                .Model<CIS_Currency>()
                .Field(new Field("MktOut_Customer")
                    .Validator(Validation.NotEmpty())
                )
                .Field(new Field("MktOut_Country")
                    .Validator(Validation.NotEmpty())
                )
                .Field(new Field("MktOut_SalesContract")
                    .Validator(Validation.NotEmpty())
                )
                .Field(new Field("MktOut_PurchaseOrder")
                    .Validator(Validation.NotEmpty())
                )
                .Field(new Field("MktOut_ShipmentDate")
                    .Validator(Validation.NotEmpty())
                )
                .Field(new Field("MktOut_Article")
                    .Validator(Validation.NotEmpty())
                ).Field(new Field("MktOut_Fabric")
                    .Validator(Validation.NotEmpty())
                ).Field(new Field("MktOut_PaymentTerms")
                    .Validator(Validation.NotEmpty())
                ).Field(new Field("MktOut_TotalQty")
                    .Validator(Validation.NotEmpty())
                )
                  .Field(new Field("MKTOut_Currency_ID")
                    .Options(new Options()
                        .Table("CIS_Currency")
                        .Value("currency_ID")
                        .Label("currency_Desc")
                    )
                 ).LeftJoin("CIS_Currency", "currency_Desc", "=", "MKTOut_Currency_ID")

// .MJoin(new MJoin("CIS_Currencies")
// .Link("MKT_Outstandings.MKTOut_Currency_ID", "CIS_Currencies.currency_Desc")
// .Field(new Field("currency_ID"))
//)
//.Field(new Field("MKT_Outstandings.CIS_Currencies")
// .Options(new Options()
// .Table("MKT_Outstandings")
// .Value("MKTOut_Currency_ID")
// .Label(new[] { "currency_ID" })
// )
//)
//.LeftJoin("MKT_Outstandings", "MKT_Outstandings.MKTOut_Currency_ID", "=", "CIS_Currencies.currency_Desc")
.Field(new Field("MktOut_Rate")
.Validator(Validation.NotEmpty())
).Field(new Field("MktOut_Amount")
.Validator(Validation.NotEmpty())
)
.TryCatch(false)
.Process(Request)
.Data();

            return Json(response);

Replies

  • mftadminmftadmin Posts: 4Questions: 1Answers: 0

    How can I get currency table ID by comparing currency table and MKT_Outstandings table. Value I need is currency_ID which is int and value I am having from frontend is string for eg. "USD" in column MKT_Outstandings.MKTOut_Currency_ID. And need its ID which is in CIS_Currencies.currency_ID and comparison column is CIS_Currencies.currency_Desc "=" MKT_Outstandings

Sign In or Register to comment.