Exemple #1
0
 public async Task <JsonResult> CreateUpdateDSPService([FromBody] DSPService dspservice)
 {
     try
     {
         return(await _dspLogic.CreateUpdateDSPService(dspservice).ConfigureAwait(false));
     }
     catch (Exception ee)
     {
         return(await _dspLogic.SendRespose("False", ee.Message).ConfigureAwait(false));
     }
 }
Exemple #2
0
        internal async Task <JsonResult> CreateUpdateDSPService(DSPService dspservice)
        {
            SqlConnection cn = null;

            try
            {
                cn = Connection.GetConnection();
                SqlCommand smd = new SqlCommand("dsp_new_service", cn)
                {
                    CommandType = CommandType.StoredProcedure
                };
                smd.Parameters.AddWithValue("@pincode", dspservice.Pincode);
                smd.Parameters.AddWithValue("@express", dspservice.Express);
                smd.Parameters.AddWithValue("@reversepickup", dspservice.ReversePickUp);
                smd.Parameters.AddWithValue("@dsp_code", dspservice.DSPCode);
                smd.Parameters.AddWithValue("@flag", dspservice.Flag);
                smd.Parameters.AddWithValue("@priority", dspservice.Priority);
                smd.Parameters.AddWithValue("@cost", dspservice.Cost);
                smd.Parameters.AddWithValue("@location_id", dspservice.LocationId);
                smd.Parameters.Add("@jsonOutput", SqlDbType.NVarChar, -1).Direction = ParameterDirection.Output;

                // Execute the command
                await smd.ExecuteNonQueryAsync().ConfigureAwait(false);

                // Get the values
                string json = smd.Parameters["@jsonOutput"].Value.ToString();
                smd.Dispose();

                JArray arr = JArray.Parse(json);

                return(new JsonResult(arr));
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                Connection.CloseConnection(ref cn);
            }
        }