예제 #1
0
        //Detail Maquinaria
        public FichaEntregaRecepcion detail(int id)
        {
            FichaEntregaRecepcion ficha = ficha_repository.detail(id);

            ficha.detalles = ficha_repository.getAllDetallesByFichaId(ficha.id);
            return(ficha);
        }
예제 #2
0
        public HttpResponseMessage detail(int id)
        {
            FichaEntregaRecepcion ficha = ficha_service.detail(id);

            if (ficha != null)
            {
                IDictionary <string, FichaEntregaRecepcion> data = new Dictionary <string, FichaEntregaRecepcion>();
                data.Add("data", ficha);
                return(Request.CreateResponse(HttpStatusCode.OK, data));
            }
            else
            {
                IDictionary <string, string> data = new Dictionary <string, string>();
                data.Add("message", "Object not found.");
                return(Request.CreateResponse(HttpStatusCode.BadRequest, data));
            }
        }
예제 #3
0
        /// <summary>
        /// Create new object on the db
        /// </summary>
        /// <param name="empleado"></param>
        /// <returns></returns>
        public int create(FichaEntregaRecepcion ficha)
        {
            SqlConnection connection = null;

            using (connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Coz_Combustibles_DB"].ConnectionString))
            {
                try
                {
                    connection.Open();
                    SqlCommand command = new SqlCommand("sp_createFichaEntrega", connection);
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.Add(new SqlParameter("usuario_entrega_id", ficha.despachador_entrega.id));
                    command.Parameters.Add(new SqlParameter("usuario_recibe_id", ficha.despachador_recibe.id));

                    SqlDataAdapter data_adapter = new SqlDataAdapter(command);
                    DataSet        data_set     = new DataSet();
                    data_adapter.Fill(data_set);
                    DataRow row = data_set.Tables[0].Rows[0];
                    return(int.Parse(row[0].ToString()));

                    //command.ExecuteNonQuery();
                    //return TransactionResult.CREATED;
                }
                catch (SqlException ex)
                {
                    if (connection != null)
                    {
                        connection.Close();
                    }
                    if (ex.Number == 2627)
                    {
                        return(0);
                    }
                    return(0);
                }
                catch
                {
                    if (connection != null)
                    {
                        connection.Close();
                    }
                    return(0);
                }
            }
        }
예제 #4
0
        public TransactionResult update(FichaEntregaRecepcion ficha)
        {
            SqlConnection connection = null;

            using (connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Coz_Combustibles_DB"].ConnectionString))
            {
                try
                {
                    connection.Open();
                    SqlCommand command = new SqlCommand("sp_updateFichaEntrega", connection);
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.Add(new SqlParameter("usuario_entrega_id", ficha.despachador_entrega.id));
                    command.Parameters.Add(new SqlParameter("usuario_recibe_id", ficha.despachador_recibe.id));
                    command.Parameters.Add(new SqlParameter("id", ficha.id));
                    command.ExecuteNonQuery();
                    return(TransactionResult.OK);
                }
                catch (SqlException ex)
                {
                    if (connection != null)
                    {
                        connection.Close();
                    }
                    if (ex.Number == 2627)
                    {
                        return(TransactionResult.EXISTS);
                    }
                    return(TransactionResult.NOT_PERMITTED);
                }
                catch
                {
                    if (connection != null)
                    {
                        connection.Close();
                    }
                    return(TransactionResult.ERROR);
                }
            }
        }
예제 #5
0
        //Create Maquinaria
        public TransactionResult create(FichaEntregaRecepcionVo ficha_vo)
        {
            FichaEntregaRecepcion ficha = FichaEntregaAdapter.voToObject(ficha_vo);
            //return maquinaria_repository.create(maquina);

            int id = ficha_repository.create(ficha);

            if (id > 0)
            {
                foreach (DetalleFichaEntregaRecepcionVo dvo in ficha_vo.detalles)
                {
                    dvo.ficha_id = id;
                    var tr2 = TransactionResult.CREATED;

                    tr2 = ficha_repository.createDetalle(DetalleFichaEntregaAdapter.voToObject(dvo));
                    if (tr2 != TransactionResult.CREATED)
                    {
                        return(tr2);
                    }
                }
                return(TransactionResult.CREATED);
            }
            return(TransactionResult.ERROR);
        }
예제 #6
0
 public static FichaEntregaRecepcionVo objectToVo(FichaEntregaRecepcion obj)
 {
     return(new FichaEntregaRecepcionVo
     {
     });
 }