Please help with simple question

Thread is closed for posting
2 posts, 0 answers
  1. Tom
    Tom avatar
    9 posts
    Member since:
    Feb 2013

    Posted 05 Jan 2017 Link to this post

    I have a WEB API application that goes against an Open Access Model.  All I want to do is do an executenonquery on a stored procedure and get back the rowsAffected. 

    I did not set up a model but I have this is the Model FluentModel file:

    public int GetPartnerShipUIUpdate(string customer_code, string cat_num, decimal Percent_NRebate, decimal Percent_SRebate,
    string part_no, int type, string comment, decimal statper, int stat_enabled, string audit_id)
    {
    int returnValue;
    return GetPartnerShipUIUpdate( customer_code, cat_num, Percent_NRebate, Percent_SRebate, part_no, type, comment, statper, stat_enabled, audit_id, out returnValue);
    }
    public int GetPartnerShipUIUpdate(string customer_code, string cat_num, decimal Percent_NRebate, decimal Percent_SRebate,
    string part_no, int type, string comment, decimal statper, int stat_enabled, string audit_id, out int returnValue)
    {
    using (FluentModel dbContext = new FluentModel())
    {
    OAParameter parameterReturnValue = new OAParameter();
    parameterReturnValue.Direction = ParameterDirection.ReturnValue;
    parameterReturnValue.ParameterName = "parameterReturnValue";
    OAParameter pcustomer_code = new OAParameter();
    pcustomer_code.ParameterName = "@customer_code";
    pcustomer_code.Value = customer_code;
    OAParameter pcat_num = new OAParameter();
    pcat_num.ParameterName = "@cat_num";
    pcat_num.Value = cat_num;
    OAParameter pPercent_NRebate = new OAParameter();
    pPercent_NRebate.ParameterName = "@Percent_NRebate";
    pPercent_NRebate.Value = Percent_NRebate;
    OAParameter pPercent_SRebate = new OAParameter();
    pPercent_SRebate.ParameterName = "@Percent_SRebate";
    pPercent_SRebate.Value = Percent_SRebate;
    OAParameter ppart_no = new OAParameter();
    ppart_no.ParameterName = "@part_no";
    ppart_no.Value = part_no;
    OAParameter ptype = new OAParameter();
    ptype.ParameterName = "@type";
    ptype.Value = type;
    OAParameter pcomment = new OAParameter();
    pcomment.ParameterName = "@comment";
    pcomment.Value = comment;
    OAParameter pstatper = new OAParameter();
    pstatper.ParameterName = "@statper";
    pstatper.Value = statper;
    OAParameter pstat_enabled = new OAParameter();
    pstat_enabled.ParameterName = "@stat_enabled";
    pstat_enabled.Value = stat_enabled;
    OAParameter paudit_id = new OAParameter();
    paudit_id.ParameterName = "@audit_id";
    paudit_id.Value = audit_id;
    int rowsAffected = ExecuteNonQuery("ROS_PartnershipUIupdate", CommandType.StoredProcedure, pcustomer_code,
    pcat_num, pPercent_NRebate, pPercent_SRebate, ppart_no, ptype, pcomment, pstatper, pstat_enabled, paudit_id, parameterReturnValue);
    returnValue = parameterReturnValue.Value == DBNull.Value
    ? -1
    : (int)parameterReturnValue.Value;
    dbContext.SaveChanges();
    return rowsAffected;
    }

     

    I am lost in the controller.  The OpenAccessBaseApiController needs an entity and I do not have an entity, just an integer returned.  I tried an APIController but I do not know how to get the parameters out of the request.

    Any help would be appreciated.  Sorry for being so clueless.

     

    Tom

  2. Tom
    Tom avatar
    9 posts
    Member since:
    Feb 2013

    Posted 13 Jan 2017 in reply to Tom Link to this post

    See here:  http://www.telerik.com/forums/webapi-controller-that-just-returns-rowsaffected-from-stored-procedure#top

     

Back to Top