public bool InsertMapping_SalaryComponents(InsertMapping_SalaryComponents obj)
        {
            bool res = false;

            foreach (var c in obj.Mapping)
            {
                SqlCommand SqlCmd = new SqlCommand("sp_InsertMappingComponents");
                SqlCmd.CommandType = CommandType.StoredProcedure;
                if (SqlCmd.Connection != null)
                {
                    if (SqlCmd.Connection.State == ConnectionState.Closed)
                    {
                        SqlCmd.Connection.Open();
                    }
                }
                SqlCmd.CommandType = CommandType.StoredProcedure;
                SqlCmd.Parameters.AddWithValue("@ComponentId", c.ComponentId);
                SqlCmd.Parameters.AddWithValue("@ManpowerId", c.ManpowerId);
                SqlCmd.Parameters.AddWithValue("@Amount", c.Amount);
                SqlCmd.Parameters.AddWithValue("@CreatedBy", c.ActionBy);
                int queryRes = _unitOfWork.DbLayer.ExecuteNonQuery(SqlCmd);
                if (queryRes != Int32.MaxValue)
                {
                    res = true;
                    SqlCmd.Connection.Close();
                }
                else
                {
                    // this part needed error handling code.
                    res = false;
                }
            }
            return(res);
        }
Exemple #2
0
        public HttpResponseMessage CreateMapping_SalaryComponents(InsertMapping_SalaryComponents obj)
        {
            HttpResponseMessage message;

            try
            {
                // Mapping_SalaryComponentsDAL dal = new Mapping_SalaryComponentsDAL();
                var dynObj = new { result = _salary.InsertMapping_SalaryComponents(obj) };
                message = Request.CreateResponse(HttpStatusCode.OK, dynObj);
            }
            catch (Exception ex)
            {
                message = Request.CreateResponse(HttpStatusCode.BadRequest, new { msgText = "Something wrong. Try Again!" });

                ErrorLog.CreateErrorMessage(ex, "Mapping_SalaryComponents", "Create Mapping_SalaryComponents");
            }
            return(message);
        }