public messageModel insert(carReasonModel value) { messageModel result = new messageModel(); try { System.Data.Entity.Core.Objects.ObjectParameter myOutputParamInt = new System.Data.Entity.Core.Objects.ObjectParameter("r_id", typeof(Int32)); using (var context = new StandardCanEntities()) { if (String.IsNullOrEmpty(value.user_id)) { throw new Exception("Unauthorized Access"); } var userId = JwtHelper.GetUserIdFromToken(value.user_id); if (String.IsNullOrEmpty(userId)) { throw new Exception("Unauthorized Access"); } int ret = context.sp_carreason_insert(value.name, value.desc, userId, myOutputParamInt); } if (myOutputParamInt.Value != null) { int r_id = Convert.ToInt32(myOutputParamInt.Value); result.status = "S"; result.message = ""; result.value = r_id.ToString(); } else { result.status = "E"; result.message = ""; } } catch (Exception ex) { result.status = "E"; result.message = ex.Message.ToString(); } return(result); }