Ejemplo n.º 1
0
        public async Task <Tuple <bool, string> > InsertStudentMapping(StudentMappingModel studentMappingModel)
        {
            Tuple <bool, string> result = null;

            try
            {
                result = await _repo.InsertStudentMapping(studentMappingModel);
            }
            catch (Exception ex)
            {
                ErrorLog.Write(ex);
            }

            return(result);
        }
        public async Task <Tuple <bool, string> > InsertStudentMapping(StudentMappingModel studentMappingModel)
        {
            Tuple <bool, string> result = null;
            int registerStatus          = -1;

            try
            {
                var parameters = new DynamicParameters();
                using (SqlConnection cxn = new SqlConnection(_dcDb))
                {
                    parameters.Add("@UserID", studentMappingModel.UserID, DbType.Int32);
                    parameters.Add("@StudentName", studentMappingModel.StudentName, DbType.String);
                    parameters.Add("@Gender", studentMappingModel.Gender, DbType.String);
                    parameters.Add("@Address1", studentMappingModel.Address1, DbType.String);
                    parameters.Add("@Address2", studentMappingModel.Address2, DbType.String);
                    parameters.Add("@City", studentMappingModel.City, DbType.String);
                    parameters.Add("@District", studentMappingModel.District, DbType.String);
                    parameters.Add("@State", studentMappingModel.State, DbType.String);
                    parameters.Add("@Country", studentMappingModel.Country, DbType.String);
                    parameters.Add("@Zipcode", studentMappingModel.Zipcode, DbType.String);
                    parameters.Add("@FeeMasterID", studentMappingModel.FeeMasterID, DbType.Int32);
                    parameters.Add("@GroupID", studentMappingModel.GroupID, DbType.Int32);
                    parameters.Add("@Fees", studentMappingModel.CourseFee, DbType.Decimal);
                    parameters.Add("@ApprovalStatusID", studentMappingModel.ApprovalStatusID, DbType.Int32);
                    parameters.Add("@TransferStatusID", studentMappingModel.TransferStatusID, DbType.Int32);
                    parameters.Add("@CreatedBy", UserID, DbType.Int32);
                    registerStatus = await cxn.ExecuteScalarAsync <int>("dbo.Insert_StudentMapping", parameters, commandType : CommandType.StoredProcedure);

                    if (registerStatus == 0)
                    {
                        result = Tuple.Create(true, "");
                    }
                    else
                    {
                        result = Tuple.Create(false, "Student mapping failed.Please try again.");
                    }

                    cxn.Close();
                }
            }
            catch (Exception ex)
            {
                ErrorLog.Write(ex);
                result = Tuple.Create(false, "Oops! Student mapping failed.Please try again.");
            }

            return(result);
        }