public BaseResponse Update_State_Reserve(EntityReserve reserve)
        {
            var returnEntity = new BaseResponse();

            try
            {
                using (var db = GetSqlConnection())
                {
                    const string sql = "udp_state_reserve";
                    var          p   = new DynamicParameters();
                    p.Add(name: "@id", value: reserve.id, dbType: DbType.Int32, direction: ParameterDirection.Input);
                    p.Add(name: "@stateReserve ", value: reserve.stateReserve, dbType: DbType.String, direction: ParameterDirection.Input);

                    db.Query <EntityReserveProduct>(sql, param: p, commandType: CommandType.StoredProcedure).FirstOrDefault();

                    returnEntity.isSuccess    = true;
                    returnEntity.errorCode    = "0000";
                    returnEntity.errorMessage = string.Empty;
                    returnEntity.data         = null;
                }
            }
            catch (Exception ex)
            {
                returnEntity.isSuccess    = false;
                returnEntity.errorCode    = "0001";
                returnEntity.errorMessage = ex.Message;
                returnEntity.data         = null;
            }
            return(returnEntity);
        }
        public BaseResponse Insert(EntityReserve reserve)
        {
            var returnEntity = new BaseResponse();

            try
            {
                using (var db = GetSqlConnection())
                {
                    /* const string sql = @"usp_InsertarProyecto";
                     *
                     * var p = new DynamicParameters();
                     * p.Add(name: "@IDPROYECTO", dbType: DbType.Int32, direction: ParameterDirection.Output);
                     * p.Add(name: "@NOMBRE", value: reserve.Nombre, dbType: DbType.String, direction: ParameterDirection.Input);
                     * p.Add(name: "@PRECIO", value: reserve.Precio, dbType: DbType.Decimal, direction: ParameterDirection.Input);
                     * p.Add(name: "@DIRECCION", value: reserve.Direccion, dbType: DbType.String, direction: ParameterDirection.Input);
                     * p.Add(name: "@UBICACION", value: reserve.Ubicacion, dbType: DbType.String, direction: ParameterDirection.Input);
                     * p.Add(name: "@USUARIOCREA", value: reserve.UsuarioCrea, dbType: DbType.Int32, direction: ParameterDirection.Input);
                     *
                     * db.Query<EntityReserve>(sql, param: p, commandType: CommandType.StoredProcedure).FirstOrDefault();
                     *
                     * int idReserve = p.Get<int>("@IDPROYECTO");
                     *
                     * if (idReserve > 0)
                     * {
                     *   returnEntity.isSuccess = true;
                     *   returnEntity.errorCode = "0000";
                     *   returnEntity.errorMessage = string.Empty;
                     *   returnEntity.data = new
                     *   {
                     *       id = idReserve,
                     *       nombre = reserve.Nombre,
                     *       precio = reserve.Precio
                     *   };
                     * }
                     * else
                     * {
                     *   returnEntity.isSuccess = false;
                     *   returnEntity.errorCode = "0000";
                     *   returnEntity.errorMessage = string.Empty;
                     *   returnEntity.data = null;
                     * }
                     */
                }
            }
            catch (Exception ex)
            {
                returnEntity.isSuccess    = false;
                returnEntity.errorCode    = "0001";
                returnEntity.errorMessage = ex.Message;
                returnEntity.data         = null;
            }

            return(returnEntity);
        }
        public ActionResult Insert(EntityReserve reserve)
        {
            var identity = User.Identity as ClaimsIdentity;
            IEnumerable <Claim> claims = identity.Claims;

            var usuarioId  = claims.Where(p => p.Type == "client_codigo_usuario").FirstOrDefault().Value;
            var usuarioDoc = claims.Where(p => p.Type == "client_numero_documento").FirstOrDefault().Value;

            reserve.UsuarioCrea = int.Parse(usuarioId);
            var ret = _ReserveRepository.Insert(reserve);

            if (ret == null)
            {
                return(StatusCode(401));
            }

            return(Json(ret));
        }
        public BaseResponse GetReserve(int id)
        {
            var returnEntity  = new BaseResponse();
            var entityReserve = new EntityReserve();

            try
            {
                using (var db = GetSqlConnection())
                {
                    const string sql = @"usp_ObtenerProyecto";
                    var          p   = new DynamicParameters();
                    p.Add(name: "@IDPROYECTO", value: id, dbType: DbType.Int32, direction: ParameterDirection.Input);

                    entityReserve = db.Query <EntityReserve>(sql, param: p, commandType: CommandType.StoredProcedure).FirstOrDefault();

                    if (entityReserve != null)
                    {
                        returnEntity.isSuccess    = true;
                        returnEntity.errorCode    = "0000";
                        returnEntity.errorMessage = string.Empty;
                        returnEntity.data         = entityReserve;
                    }
                    else
                    {
                        returnEntity.isSuccess    = false;
                        returnEntity.errorCode    = "0000";
                        returnEntity.errorMessage = string.Empty;
                        returnEntity.data         = null;
                    }
                }
            }
            catch (Exception ex)
            {
                returnEntity.isSuccess    = false;
                returnEntity.errorCode    = "0001";
                returnEntity.errorMessage = ex.Message;
                returnEntity.data         = null;
            }
            return(returnEntity);
        }
        public ActionResult Update_State_Reserve(EntityReserve reserve)
        {
            var ret = _ReserveRepository.Update_State_Reserve(reserve);

            return(Json(ret));
        }