sql server - I want help in calling below Stored procedure into my MVC model -


i have stored procedure written in sql server.

use [appmarketplace] go   set ansi_nulls on go  set quoted_identifier on go   create procedure [dbo].[uspterms]  @id int  begin set nocount on;  if(exists(select * appmarketapp id= @id)) -- checking whether user exists in main user table  begin  if(exists(select * appterms id = @id)) -- if exists in main table check in terms table accepting condition  begin return 1; -- if user has accepeted terms , condition end  else begin return 0; --if user not accepetd terms , codition end end  begin  return -1; --if user doesnt exists in appmarketapp table end end  go 

now have call in mvc model.i using ef database first approach. first question

1) need call sp in model or controller? explanation code better.

2) , looking code scenario : need write logic check whether user accepted terms , condition. if user not accepted terms should display terms , condition page , force them accept. how works first check appterms table.in table have 2 fields called id , date.if user accept terms date when user accepted stored in table thier id. if datefield empty userid means have not accepeted terms , conditon..

1) need call sp in model or controller? explanation code better.

neither, stored procedure call should in business logic layer. controller presentation layer , should deal getting data , passing onto view.

your model or viewmodel should not have business logic tied in either, should dto.


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -