Please visit DEMANDDRAFT.STORE for quality of products...

Ad

Search This Blog

Tuesday, July 7, 2015

How to insert the data using Stored Procedure in MVC4 using Data base first approach

private DBContext dbContext = new DBContext();


 public bool SaveApproveFormDetails(ApproveFromDetail approveFormDetails)
        {
            var completeId = new SqlParameter { ParameterName = "CompleteId", Value = approveFormDetails.CompleteId };

            var formCategory = new SqlParameter { ParameterName = "FormCategory", Value = approveFormDetails.FormCategory };

            var recipientReference = new SqlParameter { ParameterName = "RecipientReference", Value = approveFormDetails.RecipientReference };

            var recipientName = new SqlParameter { ParameterName = "RecipientName", Value = approveFormDetails.RecipientName };

            var formCompletedDate = new SqlParameter { ParameterName = "FormCompletedDate", Value = approveFormDetails.FormCompletedDate };

            var userLogin = new SqlParameter { ParameterName = "UserLogin", Value = approveFormDetails.UserLogin };

            var approveDate = new SqlParameter { ParameterName = "ApprovedDate", Value = approveFormDetails.ApprovedDate };

            var ApprovedBy = new SqlParameter { ParameterName = "ApprovedBy", Value = approveFormDetails.ApprovedBy };

            var ohgNotes = new SqlParameter { ParameterName = "OHGNotes", Value = approveFormDetails.OHGNotes };

            try
            {
                dbContext.Database.ExecuteSqlCommand("exec USP_SaveApproveFormDetails @CompleteId,@FormCategory,@RecipientReference,@RecipientName,@FormCompletedDate,@UserLogin,@ApprovedDate,@ApprovedBy,@OHGNotes",
                  completeId, formCategory,recipientReference,recipientName,formCompletedDate,userLogin,approveDate,ApprovedBy,ohgNotes);
                return true;
            }
            catch(Exception ex)
            {
                return false;
            }


No comments:

Post a Comment