예제 #1
0
        public long?pa_Insert_T_Campanas(DataInsertTCampana dataInsertTCampana)
        {
            var resultStoreProcedure =
                new ResultStoreProcedure(MethodBase.GetCurrentMethod(), dataInsertTCampana.ToUri());

            try
            {
                var returnParam = new SqlParameter
                {
                    ParameterName = "@return",
                    Direction     = ParameterDirection.ReturnValue
                };

                Context.Database.SqlQuery <long>(
                    "exec dbo.[pa_Insert_T_Campañas] @nsDescripcion, @dtDesde, @dtHasta",
                    new SqlParameter("@nsDescripcion", dataInsertTCampana.Descripcion),
                    new SqlParameter("@dtDesde", dataInsertTCampana.Desde),
                    new SqlParameter("@dtHasta", dataInsertTCampana.Hasta),
                    returnParam);

                resultStoreProcedure.Code = Convert.ToInt64(returnParam.Value);

                resultStoreProcedure.Status = resultStoreProcedure.Code == 1 ? Status.Ok : Status.Error;

                return(resultStoreProcedure.Code);
            }
            catch (Exception e)
            {
                resultStoreProcedure.Status      = Status.Exception;
                resultStoreProcedure.Description = e.Message;

                throw;
            }
            finally
            {
                var fileName = $"{AppDomain.CurrentDomain.BaseDirectory}\\App_Data\\log.txt";
                using (var sw = new System.IO.StreamWriter(fileName, true))
                {
                    sw.WriteLine(resultStoreProcedure.ToString());
                }
            }
        }
예제 #2
0
        public static async Task InsertCampana(DataInsertTCampana dataInsertTCampana)
        {
            Console.WriteLine("");
            Console.WriteLine("InsertCampana ...");

            if (await GetToken())
            {
                var url      = $"{_route}consolidateecat/insertcampana/?{dataInsertTCampana.ToUri()}";
                var response = await _client.GetAsync(url);

                if (response.IsSuccessStatusCode)
                {
                    var code = await response.Content.ReadAsStringAsync();

                    Console.WriteLine($"InsertCampana [code] -> {code}");
                }
                else
                {
                    Console.WriteLine($"InsertCampanas -> {response.StatusCode}");
                }
            }
        }
예제 #3
0
 public IHttpActionResult pa_Insert_T_Campanas([FromUri] DataInsertTCampana dataInsertTCampana)
 {
     return(Json(_serviceTCampanas.pa_Insert_T_Campanas(dataInsertTCampana)));
 }
예제 #4
0
        public static List <ResultStoreProcedure> InsertCampana(string connectionString, DataInsertTCampana dataInsertTCampana)
        {
            var listResultStoreProcedure = new List <ResultStoreProcedure>();
            var resultStoreProcedure     = new ResultStoreProcedure(MethodBase.GetCurrentMethod(), dataInsertTCampana.ToUri());

            listResultStoreProcedure.Add(resultStoreProcedure);

            try
            {
                using (var sqlConnection = new SqlConnection(connectionString))
                {
                    sqlConnection.Open();
                    using (var sqlCommand = new SqlCommand())
                    {
                        sqlCommand.Connection  = sqlConnection;
                        sqlCommand.CommandType = CommandType.StoredProcedure;
                        sqlCommand.CommandText = "pa_Insert_T_Campañas";

                        sqlCommand.Parameters.Add(new SqlParameter("@nsDescripcion", dataInsertTCampana.Descripcion));
                        sqlCommand.Parameters.Add(new SqlParameter("@dtDesde", dataInsertTCampana.Desde));
                        sqlCommand.Parameters.Add(new SqlParameter("@dtHasta", dataInsertTCampana.Hasta));

                        var returnParam = new SqlParameter
                        {
                            ParameterName = "@return",
                            Direction     = ParameterDirection.ReturnValue
                        };
                        sqlCommand.Parameters.Add(returnParam);

                        sqlCommand.ExecuteNonQuery();
                        resultStoreProcedure.Code = Convert.ToInt64(returnParam.Value);

                        resultStoreProcedure.Status      = resultStoreProcedure.Code > 0 ? Status.Ok : Status.Error;
                        resultStoreProcedure.Description = GetDescriptionError(resultStoreProcedure.Code);
                        Util.WriteLog(resultStoreProcedure);

                        return(listResultStoreProcedure);
                    }
                }
            }
            catch (Exception e)
            {
                resultStoreProcedure.Status      = Status.Exception;
                resultStoreProcedure.Description = e.Message;

                return(listResultStoreProcedure);
            }
        }
예제 #5
0
 public long?pa_Insert_T_Campanas(DataInsertTCampana dataInsertTCampana)
 {
     return(_repositoryTCampanas.pa_Insert_T_Campanas(dataInsertTCampana));
 }
예제 #6
0
 public IHttpActionResult InsertCampana([FromUri] DataInsertTCampana dataInsertTCampana)
 {
     return(Json(ServiceMasterMaintenance.InsertCampana(
                     System.Configuration.ConfigurationManager.ConnectionStrings["Context"].ConnectionString,
                     dataInsertTCampana)));
 }