This is a migrated thread and some comments may be shown as answers.

Please help with simple question

1 Answer 10 Views
Data Access Free Edition
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Tom
Top achievements
Rank 1
Tom asked on 05 Jan 2017, 09:25 PM

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

1 Answer, 1 is accepted

Sort by
0
Tom
Top achievements
Rank 1
answered on 13 Jan 2017, 08:10 PM

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

 

Tags
Data Access Free Edition
Asked by
Tom
Top achievements
Rank 1
Answers by
Tom
Top achievements
Rank 1
Share this question
or